-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[InstCombine] Replace an integer comparison of a phi
node with multiple ucmp
/scmp
operands and a constant with phi
of individual comparisons of original intrinsic's arguments
#107769
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 3 commits
6f7fa77
c3424e7
833e168
bbeded8
3a8efdf
a7a2930
b5fe2cc
45157a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. Can you please also add negative tests where one scmp is not one-use or the icmp operand is not constant? 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. The case you're proposing would still actually enable this optimization since we can still move the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
||
define i1 @icmp_of_phi_of_scmp_with_constant(i1 %c, i16 %x, i16 %y) | ||
; CHECK-LABEL: define i1 @icmp_of_phi_of_scmp_with_constant( | ||
; CHECK-SAME: i1 [[C:%.*]], i16 [[X:%.*]], i16 [[Y:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br i1 [[C]], label %[[TRUE:.*]], label %[[FALSE:.*]] | ||
; CHECK: [[TRUE]]: | ||
; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i16 [[X]], [[Y]] | ||
; CHECK-NEXT: br label %[[EXIT:.*]] | ||
; CHECK: [[FALSE]]: | ||
; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i16 [[Y]], [[X]] | ||
; CHECK-NEXT: br label %[[EXIT]] | ||
; CHECK: [[EXIT]]: | ||
; CHECK-NEXT: [[R:%.*]] = phi i1 [ [[TMP0]], %[[TRUE]] ], [ [[TMP1]], %[[FALSE]] ] | ||
; CHECK-NEXT: ret i1 [[R]] | ||
; | ||
{ | ||
entry: | ||
br i1 %c, label %true, label %false | ||
true: | ||
%cmp1 = call i8 @llvm.scmp(i16 %x, i16 %y) | ||
br label %exit | ||
false: | ||
%cmp2 = call i8 @llvm.scmp(i16 %y, i16 %x) | ||
br label %exit | ||
exit: | ||
%phi = phi i8 [%cmp1, %true], [%cmp2, %false] | ||
%r = icmp slt i8 %phi, 0 | ||
ret i1 %r | ||
} |
Uh oh!
There was an error while loading. Please reload this page.