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

InstSimplify incorrectly folds signed comparisons of 'gep inbounds' #51771

Closed
nunoplopes opened this issue Nov 5, 2021 · 2 comments
Closed
Labels
bugzilla Issues migrated from bugzilla miscompilation

Comments

@nunoplopes
Copy link
Member

Bugzilla Link 52429
Resolution FIXED
Resolved on Nov 06, 2021 20:12
Version trunk
OS All
CC @aqjune,@LebedevRI,@RKSimon,@nikic,@regehr,@sanjoy
Fixed by commit(s) e3cec17

Extended Description

File: Transforms/InstSimplify/compare.ll

define i1 @​gep_same_base_constant_indices(i8* %a) {
; CHECK-NEXT: ret i1 true
;
%arrayidx1 = getelementptr inbounds i8, i8* %a, i64 1
%arrayidx2 = getelementptr inbounds i8, i8* %a, i64 10
%cmp = icmp slt i8* %arrayidx1, %arrayidx2
ret i1 %cmp
}

Folding such unsigned comparisons is correct, but not for signed as an object may cross the unsigned/signed line, e.g:
ptr = malloc(42) // 0x7fff..ff0
ptr + 42 // 0x8....

@nikic
Copy link
Contributor

nikic commented Nov 6, 2021

@nikic
Copy link
Contributor

nikic commented Nov 6, 2021

Fixed by e3cec17.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 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 miscompilation
Projects
None yet
Development

No branches or pull requests

2 participants