-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect #87075
Merged
Merged
[InstSimplify] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect #87075
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s | ||
|
||
; %or2 cannot be folded into %or1 because %or1 has disjoint. | ||
; TODO: Can we move the logic into InstCombine and drop the disjoint flag? | ||
define i64 @test(i1 %cond, i64 %x) { | ||
; CHECK-LABEL: define i64 @test( | ||
; CHECK-SAME: i1 [[COND:%.*]], i64 [[X:%.*]]) { | ||
; CHECK-NEXT: [[OR1:%.*]] = or disjoint i64 [[X]], 7 | ||
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[COND]], i64 [[OR1]], i64 [[X]] | ||
; CHECK-NEXT: [[OR2:%.*]] = or i64 [[SEL1]], 7 | ||
; CHECK-NEXT: ret i64 [[OR2]] | ||
; | ||
%or1 = or disjoint i64 %x, 7 | ||
%sel1 = select i1 %cond, i64 %or1, i64 %x | ||
%or2 = or i64 %sel1, 7 | ||
ret i64 %or2 | ||
} | ||
|
||
define i64 @pr87042(i64 %x) { | ||
; CHECK-LABEL: define i64 @pr87042( | ||
; CHECK-SAME: i64 [[X:%.*]]) { | ||
; CHECK-NEXT: [[AND1:%.*]] = and i64 [[X]], 65535 | ||
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i64 [[AND1]], 0 | ||
; CHECK-NEXT: [[OR1:%.*]] = or disjoint i64 [[X]], 7 | ||
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[CMP1]], i64 [[OR1]], i64 [[X]] | ||
; CHECK-NEXT: [[AND2:%.*]] = and i64 [[SEL1]], 16776960 | ||
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i64 [[AND2]], 0 | ||
; CHECK-NEXT: [[OR2:%.*]] = or i64 [[SEL1]], 7 | ||
; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[CMP2]], i64 [[OR2]], i64 [[SEL1]] | ||
; CHECK-NEXT: ret i64 [[SEL2]] | ||
; | ||
%and1 = and i64 %x, 65535 | ||
%cmp1 = icmp eq i64 %and1, 0 | ||
%or1 = or disjoint i64 %x, 7 | ||
%sel1 = select i1 %cmp1, i64 %or1, i64 %x | ||
%and2 = and i64 %sel1, 16776960 | ||
%cmp2 = icmp eq i64 %and2, 0 | ||
%or2 = or i64 %sel1, 7 | ||
%sel2 = select i1 %cmp2, i64 %or2, i64 %sel1 | ||
ret i64 %sel2 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't
isSafeToSpeculativelyExecute
suffice here?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.
isSafeToSpeculativelyExecute
only cares about immediate UB instead of poison.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.
why is the fix to prohibit any poison flag and not to just drop the poison generating flag?
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.
IIRC modifying an instruction is not allowed in InstSimplify :(
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.
oh yeah xD
Maybe just move this to InstCombine? Or put equivelent code that drops poison generating flags there?