Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed simplification with not #47202

Closed
davidbolvansky opened this issue Oct 15, 2020 · 2 comments
Closed

Missed simplification with not #47202

davidbolvansky opened this issue Oct 15, 2020 · 2 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@davidbolvansky
Copy link
Collaborator

Bugzilla Link 47858
Resolution FIXED
Resolved on Oct 25, 2020 10:04
Version trunk
OS Linux
CC @RKSimon,@rotateright
Fixed by commit(s) e77ba26

Extended Description

void foo(void);

void s(unsigned a, unsigned b)
{
unsigned x = ~b;

    if (x > 0 && x > a)                                                                             
            foo();                                                                  

}

Clang -O3:

s(unsigned int, unsigned int): # @​s(unsigned int, unsigned int)
cmp esi, -1
je .LBB0_2
not esi
cmp esi, edi
jbe .LBB0_2
jmp foo() # TAILCALL
.LBB0_2:
ret

GCC -O3:
s(unsigned int, unsigned int):
not esi
cmp esi, edi
ja .L4
ret
.L4:
jmp foo()

@rotateright
Copy link
Contributor

define i1 @​src(i32 %a, i32 %b) {
%neg = xor i32 %b, -1
%cmp.not = icmp ne i32 %b, -1
%cmp1 = icmp ugt i32 %neg, %a
%r = and i1 %cmp.not, %cmp1
ret i1 %r
}

define i1 @​tgt(i32 %a, i32 %b) {
%neg = xor i32 %b, -1
%cmp1 = icmp ugt i32 %neg, %a
ret i1 %cmp1
}


Logic-of-icmps - we probably want a generalization that matches a negated operand on 1 side and a signed or unsigned limit constant on the other.

@rotateright
Copy link
Contributor

Should be fixed with:
https://reviews.llvm.org/rGe77ba263fe0e

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants