-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[UnifyLoopExits] Never generate phis of only undef
values
#99924
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
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes='unify-loop-exits' -S | FileCheck %s | ||
|
||
define fastcc void @undef_phi(i64 %i5247, i1 %i4530, i1 %i4936.not) { | ||
; CHECK-LABEL: define fastcc void @undef_phi( | ||
; CHECK-SAME: i64 [[I5247:%.*]], i1 [[I4530:%.*]], i1 [[I4936_NOT:%.*]]) { | ||
; CHECK-NEXT: [[BB:.*:]] | ||
; CHECK-NEXT: br label %[[MBB3932:.*]] | ||
; CHECK: [[MBB3932]]: | ||
; CHECK-NEXT: br label %[[MBB4454:.*]] | ||
; CHECK: [[MBB4321:.*]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[I5247]] to i32 | ||
; CHECK-NEXT: [[I5290:%.*]] = icmp eq i32 [[TMP0]], 0 | ||
; CHECK-NEXT: br i1 [[I5290]], label %[[MBB3932]], label %[[LOOP_EXIT_GUARD:.*]] | ||
; CHECK: [[MBB4454]]: | ||
; CHECK-NEXT: br i1 [[I4530]], label %[[MBB4535:.*]], label %[[LOOP_EXIT_GUARD1:.*]] | ||
; CHECK: [[MBB4531:.*]]: | ||
; CHECK-NEXT: ret void | ||
; CHECK: [[MBB4535]]: | ||
; CHECK-NEXT: br i1 [[I4936_NOT]], label %[[LOOP_EXIT_GUARD1]], label %[[MBB4454]] | ||
; CHECK: [[MBB5291:.*]]: | ||
; CHECK-NEXT: [[I5293:%.*]] = insertvalue [2 x i32] zeroinitializer, i32 [[DOTMOVED:%.*]], 1 | ||
; CHECK-NEXT: store volatile [2 x i32] [[I5293]], ptr addrspace(5) null, align 4 | ||
; CHECK-NEXT: ret void | ||
; CHECK: [[LOOP_EXIT_GUARD]]: | ||
; CHECK-NEXT: [[DOTMOVED]] = phi i32 [ [[TMP0]], %[[MBB4321]] ], [ undef, %[[LOOP_EXIT_GUARD1]] ] | ||
; CHECK-NEXT: [[GUARD_MBB4531:%.*]] = phi i1 [ false, %[[MBB4321]] ], [ [[GUARD_MBB4531_MOVED:%.*]], %[[LOOP_EXIT_GUARD1]] ] | ||
; CHECK-NEXT: br i1 [[GUARD_MBB4531]], label %[[MBB4531]], label %[[MBB5291]] | ||
; CHECK: [[LOOP_EXIT_GUARD1]]: | ||
; CHECK-NEXT: [[GUARD_MBB4531_MOVED]] = phi i1 [ true, %[[MBB4454]] ], [ undef, %[[MBB4535]] ] | ||
; CHECK-NEXT: [[GUARD_LOOP_EXIT_GUARD:%.*]] = phi i1 [ true, %[[MBB4454]] ], [ false, %[[MBB4535]] ] | ||
; CHECK-NEXT: br i1 [[GUARD_LOOP_EXIT_GUARD]], label %[[LOOP_EXIT_GUARD]], label %[[MBB4321]] | ||
; | ||
mbb: | ||
br label %mbb3932 | ||
|
||
mbb3932: ; preds = %mbb4321, %mbb | ||
br label %mbb4454 | ||
|
||
mbb4321: ; preds = %mbb4535 | ||
%0 = trunc i64 %i5247 to i32 | ||
%i5290 = icmp eq i32 %0, 0 | ||
br i1 %i5290, label %mbb3932, label %mbb5291 | ||
|
||
mbb4454: ; preds = %mbb4535, %mbb3932 | ||
br i1 %i4530, label %mbb4535, label %mbb4531 | ||
|
||
mbb4531: ; preds = %mbb4454 | ||
ret void | ||
|
||
mbb4535: ; preds = %mbb4454 | ||
br i1 %i4936.not, label %mbb4321, label %mbb4454 | ||
|
||
mbb5291: ; preds = %mbb4321 | ||
%i5293 = insertvalue [2 x i32] zeroinitializer, i32 %0, 1 | ||
store volatile [2 x i32] %i5293, ptr addrspace(5) null, align 4 | ||
ret void | ||
} |
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.
Should this try to preserve 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.
As of right now, this emits undef by default. We likely want to change both UndefValue::get to poison. Should I include that and track undef/poison separately?
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 probably makes little difference, can switch these to poison as a second step?
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.
OK, let's do this first, then we switch to 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.
I didn't really understand. Are we agreeing that it's okay to temporarily ignore
UndefValue
that are actually poison in this patch?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.
All poisons are undef. Not all undefs are poison. It's safe, though suboptimal, to replace poison with undef