-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[ValueTracking] Improve KnownBits for signed min-max clamping #120576
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
Changes from 2 commits
cb2efa6
54b6643
a72e960
6636dc6
5422719
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,174 @@ | ||||||
| ; RUN: opt < %s -passes=aggressive-instcombine -mtriple=x86_64 -S | FileCheck %s | ||||||
dtcxzyw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| ; RUN: opt < %s -passes=aggressive-instcombine -mtriple=x86_64 -S | FileCheck %s | |
| ; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s |
Please add an appropriate data layout instead, something like target datalayout = "n:32:16:8" probably works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added target datalayout = "n8:16:32", removed -mtriple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*CHighshould be included by ConstantRange.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It produces a wrong KnownBits result
00000000000?????forsmax(smin(X, 32), 0).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an counterexample: https://alive2.llvm.org/ce/z/ji-_Jq
Output:
%andshould not be eliminated.Please add this negative test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, my mistake. I also checked that this is ok if *CHigh is MaxSignedValue (in this case +1 loops to MinSignedValue and ConstantRange interprets this correctly). I added 3 more LIT tests: two to check that +1 is correct now and one to verify that MaxSignedValue is dealt with correctly.