summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-02-19 21:46:13 +0000
committerSanjay Patel <spatel@rotateright.com>2019-02-19 21:46:13 +0000
commitdcb93c0ddacded19a70964ab32ba01ec5e988a4f (patch)
tree3b68c96ca051ba6e6069b250a841b3b615f4d7b5 /llvm/test
parent9845da93e1253aa10ad2c8ee87a89b5ca4e896ad (diff)
downloadbcm5719-llvm-dcb93c0ddacded19a70964ab32ba01ec5e988a4f.tar.gz
bcm5719-llvm-dcb93c0ddacded19a70964ab32ba01ec5e988a4f.zip
[InstCombine] rearrange saturated add folds; NFC
This is no-functional-change-intended, but that was also true when it was part of rL354276, and I managed to lose 2 predicates for the fold with constant...causing much bot distress. So this time I'm adding a couple of negative tests to avoid that. llvm-svn: 354384
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstCombine/saturating-add-sub.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
index de3af0008c9..da3daecf393 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -771,6 +771,36 @@ define i32 @uadd_sat_commute_select_ugt_commute_add(i32 %xp, i32 %y) {
ret i32 %r
}
+; Negative test - make sure we have a -1 in the select.
+
+define i32 @not_uadd_sat(i32 %x, i32 %y) {
+; CHECK-LABEL: @not_uadd_sat(
+; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], -2
+; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[X]], 1
+; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 [[A]], i32 [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %a = add i32 %x, -2
+ %c = icmp ugt i32 %x, 1
+ %r = select i1 %c, i32 %a, i32 %y
+ ret i32 %r
+}
+
+; Negative test - make sure the predicate is 'ult'.
+
+define i32 @not_uadd_sat2(i32 %x, i32 %y) {
+; CHECK-LABEL: @not_uadd_sat2(
+; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], -2
+; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[X]], 1
+; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 [[A]], i32 -1
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %a = add i32 %x, -2
+ %c = icmp ugt i32 %x, 1
+ %r = select i1 %c, i32 %a, i32 -1
+ ret i32 %r
+}
+
define i32 @uadd_sat_constant(i32 %x) {
; CHECK-LABEL: @uadd_sat_constant(
; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], 42
OpenPOWER on IntegriCloud