[llvm] r354223 - [InstCombine] add more tests for unsigned saturated add; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 17 08:44:11 PST 2019
Author: spatel
Date: Sun Feb 17 08:44:11 2019
New Revision: 354223
URL: http://llvm.org/viewvc/llvm-project?rev=354223&view=rev
Log:
[InstCombine] add more tests for unsigned saturated add; NFC
Extend the pattern-matching from rL354219 / rL354221.
Modified:
llvm/trunk/test/Transforms/InstCombine/saturating-add-sub.ll
Modified: llvm/trunk/test/Transforms/InstCombine/saturating-add-sub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/saturating-add-sub.ll?rev=354223&r1=354222&r2=354223&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/saturating-add-sub.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/saturating-add-sub.ll Sun Feb 17 08:44:11 2019
@@ -653,8 +653,8 @@ define i32 @uadd_sat(i32 %x, i32 %y) {
ret i32 %r
}
-define i32 @uadd_sat_commute1(i32 %xp, i32 %y) {
-; CHECK-LABEL: @uadd_sat_commute1(
+define i32 @uadd_sat_commute_add(i32 %xp, i32 %y) {
+; CHECK-LABEL: @uadd_sat_commute_add(
; CHECK-NEXT: [[X:%.*]] = urem i32 42, [[XP:%.*]]
; CHECK-NEXT: [[A:%.*]] = add i32 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A]], [[Y]]
@@ -668,6 +668,42 @@ define i32 @uadd_sat_commute1(i32 %xp, i
%r = select i1 %c, i32 -1, i32 %a
ret i32 %r
}
+
+define i32 @uadd_sat_ugt(i32 %x, i32 %yp) {
+; CHECK-LABEL: @uadd_sat_ugt(
+; CHECK-NEXT: [[Y:%.*]] = sdiv i32 [[YP:%.*]], 2442
+; CHECK-NEXT: [[NOTX:%.*]] = xor i32 [[X:%.*]], -1
+; CHECK-NEXT: [[A:%.*]] = add i32 [[Y]], [[X]]
+; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[Y]], [[NOTX]]
+; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 -1, i32 [[A]]
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %y = sdiv i32 %yp, 2442 ; thwart complexity-based-canonicalization
+ %notx = xor i32 %x, -1
+ %a = add i32 %y, %x
+ %c = icmp ugt i32 %y, %notx
+ %r = select i1 %c, i32 -1, i32 %a
+ ret i32 %r
+}
+
+define i32 @uadd_sat_ugt_commute_add(i32 %xp, i32 %yp) {
+; CHECK-LABEL: @uadd_sat_ugt_commute_add(
+; CHECK-NEXT: [[Y:%.*]] = sdiv i32 [[YP:%.*]], 2442
+; CHECK-NEXT: [[X:%.*]] = srem i32 42, [[XP:%.*]]
+; CHECK-NEXT: [[NOTX:%.*]] = xor i32 [[X]], -1
+; CHECK-NEXT: [[A:%.*]] = add i32 [[X]], [[Y]]
+; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[Y]], [[NOTX]]
+; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 -1, i32 [[A]]
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %y = sdiv i32 %yp, 2442 ; thwart complexity-based-canonicalization
+ %x = srem i32 42, %xp ; thwart complexity-based-canonicalization
+ %notx = xor i32 %x, -1
+ %a = add i32 %x, %y
+ %c = icmp ugt i32 %y, %notx
+ %r = select i1 %c, i32 -1, i32 %a
+ ret i32 %r
+}
define i32 @uadd_sat_constant(i32 %x) {
; CHECK-LABEL: @uadd_sat_constant(
More information about the llvm-commits
mailing list