-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ConstraintElim] Teach checkAndReplaceCondition about samesign #128168
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 all commits
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 |
---|---|---|
|
@@ -303,3 +303,64 @@ define i1 @ugt_assumed_positive_values(i8 %a, i8 %b) { | |
|
||
ret i1 %result | ||
} | ||
|
||
define i1 @implied_condition_sgt_ugt(i8 %a, i8 %b) { | ||
; CHECK-LABEL: @implied_condition_sgt_ugt( | ||
; CHECK-NEXT: [[CMP_SGT:%.*]] = icmp sgt i8 [[A:%.*]], [[B:%.*]] | ||
; CHECK-NEXT: br i1 [[CMP_SGT]], label [[GREATER:%.*]], label [[EXIT:%.*]] | ||
; CHECK: greater: | ||
; CHECK-NEXT: ret i1 true | ||
; CHECK: exit: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cmp_sgt = icmp sgt i8 %a, %b | ||
br i1 %cmp_sgt, label %greater, label %exit | ||
|
||
greater: | ||
%cmp_ugt = icmp samesign ugt i8 %a, %b | ||
ret i1 %cmp_ugt | ||
|
||
exit: | ||
ret i1 false | ||
} | ||
|
||
define i1 @implied_condition_sle_ule(i8 %a) { | ||
; CHECK-LABEL: @implied_condition_sle_ule( | ||
; CHECK-NEXT: [[CMP_SLE:%.*]] = icmp sle i8 [[A:%.*]], 42 | ||
; CHECK-NEXT: br i1 [[CMP_SLE]], label [[LESS_OR_EQUAL:%.*]], label [[EXIT:%.*]] | ||
; CHECK: less_or_equal: | ||
; CHECK-NEXT: ret i1 true | ||
; CHECK: exit: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cmp_sle = icmp sle i8 %a, 42 | ||
br i1 %cmp_sle, label %less_or_equal, label %exit | ||
|
||
less_or_equal: | ||
%cmp_ule = icmp samesign ule i8 %a, 42 | ||
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. could you also add a test with And maybe a variant with 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.
Based on comments above, I thought 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. Unless I misunderstood something, @fhahn: 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. Yep, AFAIK you can have |
||
ret i1 %cmp_ule | ||
|
||
exit: | ||
ret i1 false | ||
} | ||
|
||
define i1 @implied_condition_cannot_simplify(i8 %a, i8 %b) { | ||
; CHECK-LABEL: @implied_condition_cannot_simplify( | ||
; CHECK-NEXT: [[CMP_SGT:%.*]] = icmp ne i8 [[A:%.*]], [[B:%.*]] | ||
; CHECK-NEXT: br i1 [[CMP_SGT]], label [[GREATER:%.*]], label [[EXIT:%.*]] | ||
; CHECK: not_equal: | ||
; CHECK-NEXT: [[CMP_UGT:%.*]] = icmp samesign ugt i8 [[A]], [[B]] | ||
; CHECK-NEXT: ret i1 [[CMP_UGT]] | ||
; CHECK: exit: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cmp_ne = icmp ne i8 %a, %b | ||
br i1 %cmp_ne, label %not_equal, label %exit | ||
|
||
not_equal: | ||
%cmp_ugt = icmp samesign ugt i8 %a, %b | ||
ret i1 %cmp_ugt | ||
|
||
exit: | ||
ret i1 false | ||
} |
Uh oh!
There was an error while loading. Please reload this page.