-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[InstCombine] Fix pointer replacement in foldSelectValueEquivalence
#161701
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 4 commits
3349520
18f21c6
44f9269
9a0f030
07a43ac
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -286,3 +286,35 @@ define <2 x ptr> @test7(<2 x ptr> %p1, i64 %idx, <2 x i1> %cc) { | |||||||
%select = select <2 x i1> %cc, <2 x ptr> %p1, <2 x ptr> %gep | ||||||||
ret <2 x ptr> %select | ||||||||
} | ||||||||
|
||||||||
define ptr @ptr_eq_replace_freeze1(ptr %p, ptr %q) { | ||||||||
; CHECK-LABEL: @ptr_eq_replace_freeze1( | ||||||||
; CHECK-NEXT: [[Q_FR:%.*]] = freeze ptr [[Q:%.*]] | ||||||||
; CHECK-NEXT: [[Q_FR1:%.*]] = freeze ptr [[Q1:%.*]] | ||||||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[Q_FR]], [[Q_FR1]] | ||||||||
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], ptr [[Q_FR]], ptr [[Q_FR1]] | ||||||||
; CHECK-NEXT: ret ptr [[SELECT]] | ||||||||
; | ||||||||
%p.fr = freeze ptr %p | ||||||||
%q.fr = freeze ptr %q | ||||||||
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. What is the significance of freeze here? Why does this issue not reproduce without it (or with just noundef)? 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. It is guarded by llvm-project/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp Lines 1456 to 1458 in bd7e228
|
||||||||
%cmp = icmp eq ptr %p.fr, %q.fr | ||||||||
%select = select i1 %cmp, ptr %p.fr, ptr %q.fr | ||||||||
ret ptr %select | ||||||||
} | ||||||||
|
||||||||
define ptr @ptr_eq_replace_freeze2(ptr %p, ptr %q) { | ||||||||
; CHECK-LABEL: @ptr_eq_replace_freeze2( | ||||||||
; CHECK-NEXT: [[P_FR:%.*]] = freeze ptr [[P:%.*]] | ||||||||
; CHECK-NEXT: [[P_FR1:%.*]] = freeze ptr [[P1:%.*]] | ||||||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P_FR1]], [[P_FR]] | ||||||||
; CHECK-NEXT: [[SELECT_V:%.*]] = select i1 [[CMP]], ptr [[P_FR1]], ptr [[P_FR]] | ||||||||
; CHECK-NEXT: [[SELECT:%.*]] = getelementptr i8, ptr [[SELECT_V]], i64 16 | ||||||||
; CHECK-NEXT: ret ptr [[SELECT]] | ||||||||
; | ||||||||
%gep1 = getelementptr i32, ptr %p, i64 4 | ||||||||
%gep2 = getelementptr i32, ptr %q, i64 4 | ||||||||
%cmp = icmp eq ptr %p, %q | ||||||||
%cmp.fr = freeze i1 %cmp | ||||||||
%select = select i1 %cmp.fr, ptr %gep1, ptr %gep2 | ||||||||
ret ptr %select | ||||||||
} |
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.
Unused Direction argument?