-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[InstCombine] Allow freezing multiple operands #154336
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
Merged
+159
−148
Merged
Changes from all commits
Commits
Show all changes
3 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
---|---|---|---|---|
|
@@ -2847,7 +2847,8 @@ define void @cond_freeze_multipleuses(i8 %x, i8 %y) { | |||
define i32 @select_freeze_icmp_eq(i32 %x, i32 %y) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comes from:
We regress this case by inserting an unnecessary freeze now, but I don't think this is important. We can drop the specialized transform after this patch. |
||||
; CHECK-LABEL: define i32 @select_freeze_icmp_eq( | ||||
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { | ||||
; CHECK-NEXT: ret i32 [[Y]] | ||||
; CHECK-NEXT: [[Y_FR:%.*]] = freeze i32 [[Y]] | ||||
; CHECK-NEXT: ret i32 [[Y_FR]] | ||||
; | ||||
%c = icmp eq i32 %x, %y | ||||
%c.fr = freeze i1 %c | ||||
|
@@ -2858,7 +2859,8 @@ define i32 @select_freeze_icmp_eq(i32 %x, i32 %y) { | |||
define i32 @select_freeze_icmp_ne(i32 %x, i32 %y) { | ||||
; CHECK-LABEL: define i32 @select_freeze_icmp_ne( | ||||
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { | ||||
; CHECK-NEXT: ret i32 [[X]] | ||||
; CHECK-NEXT: [[X_FR:%.*]] = freeze i32 [[X]] | ||||
; CHECK-NEXT: ret i32 [[X_FR]] | ||||
; | ||||
%c = icmp ne i32 %x, %y | ||||
%c.fr = freeze i1 %c | ||||
|
@@ -2869,9 +2871,9 @@ define i32 @select_freeze_icmp_ne(i32 %x, i32 %y) { | |||
define i32 @select_freeze_icmp_else(i32 %x, i32 %y) { | ||||
; CHECK-LABEL: define i32 @select_freeze_icmp_else( | ||||
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { | ||||
; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[X]], [[Y]] | ||||
; CHECK-NEXT: [[C_FR:%.*]] = freeze i1 [[C]] | ||||
; CHECK-NEXT: [[V:%.*]] = select i1 [[C_FR]], i32 [[X]], i32 [[Y]] | ||||
; CHECK-NEXT: [[Y_FR:%.*]] = freeze i32 [[Y]] | ||||
; CHECK-NEXT: [[X_FR:%.*]] = freeze i32 [[X]] | ||||
; CHECK-NEXT: [[V:%.*]] = call i32 @llvm.umin.i32(i32 [[X_FR]], i32 [[Y_FR]]) | ||||
; CHECK-NEXT: ret i32 [[V]] | ||||
; | ||||
%c = icmp ult i32 %x, %y | ||||
|
@@ -2885,9 +2887,9 @@ declare void @use_i1_i32(i1, i32) | |||
define void @select_freeze_icmp_multuses(i32 %x, i32 %y) { | ||||
; CHECK-LABEL: define void @select_freeze_icmp_multuses( | ||||
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) { | ||||
; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[X]], [[Y]] | ||||
; CHECK-NEXT: [[C_FR:%.*]] = freeze i1 [[C]] | ||||
; CHECK-NEXT: [[V:%.*]] = select i1 [[C_FR]], i32 [[X]], i32 [[Y]] | ||||
; CHECK-NEXT: [[Y_FR:%.*]] = freeze i32 [[Y]] | ||||
; CHECK-NEXT: [[V:%.*]] = freeze i32 [[X]] | ||||
; CHECK-NEXT: [[C_FR:%.*]] = icmp ne i32 [[V]], [[Y_FR]] | ||||
; CHECK-NEXT: call void @use_i1_i32(i1 [[C_FR]], i32 [[V]]) | ||||
; CHECK-NEXT: ret void | ||||
; | ||||
|
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
could the PHI node restriction also be removed so freeze can be pushed through PHIs?
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.
The phi case is trickier because we need to make sure that we don't end up pushing a freeze around a loop. We should at least extend foldFreezeIntoRecurrence() to allow freezing multiple out-of-loop values though.