[llvm] e028121 - [InstCombine] add/move tests for add with select operands that simplify; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 6 09:20:12 PDT 2022
Author: Sanjay Patel
Date: 2022-09-06T12:19:50-04:00
New Revision: e028121ed0fefe0693cdc7ff59aabba931519170
URL: https://github.com/llvm/llvm-project/commit/e028121ed0fefe0693cdc7ff59aabba931519170
DIFF: https://github.com/llvm/llvm-project/commit/e028121ed0fefe0693cdc7ff59aabba931519170.diff
LOG: [InstCombine] add/move tests for add with select operands that simplify; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll
llvm/test/Transforms/InstCombine/add.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll b/llvm/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll
index 1efc5bdea95e..11c2ebd3b18c 100644
--- a/llvm/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll
+++ b/llvm/test/Transforms/InstCombine/2007-12-18-AddSelCmpSub.ll
@@ -30,16 +30,3 @@ define i32 @bar(i32 %a) {
%t12 = add i32 %smax, %a
ret i32 %t12
}
-
-define i32 @fun(i32 %a) {
-; CHECK-LABEL: @fun(
-; CHECK-NEXT: [[T16:%.*]] = icmp slt i32 [[A:%.*]], 0
-; CHECK-NEXT: [[T12:%.*]] = select i1 [[T16]], i32 [[A]], i32 99
-; CHECK-NEXT: ret i32 [[T12]]
-;
- %t15 = sub i32 99, %a
- %t16 = icmp slt i32 %a, 0
- %smax = select i1 %t16, i32 0, i32 %t15
- %t12 = add i32 %smax, %a
- ret i32 %t12
-}
diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll
index 01d4319805b4..b6ffa0015a78 100644
--- a/llvm/test/Transforms/InstCombine/add.ll
+++ b/llvm/test/Transforms/InstCombine/add.ll
@@ -2059,3 +2059,54 @@ define i8 @select_negate_or_nonzero_use(i1 %b, i8 %x, i8 %y) {
%add = add i8 %sel, %y
ret i8 %add
}
+
+define i32 @add_select_sub_both_arms_simplify(i1 %b, i32 %a) {
+; CHECK-LABEL: @add_select_sub_both_arms_simplify(
+; CHECK-NEXT: [[ADD:%.*]] = select i1 [[B:%.*]], i32 [[A:%.*]], i32 99
+; CHECK-NEXT: ret i32 [[ADD]]
+;
+ %sub = sub i32 99, %a
+ %sel = select i1 %b, i32 0, i32 %sub
+ %add = add i32 %sel, %a
+ ret i32 %add
+}
+
+define <2 x i8> @add_select_sub_both_arms_simplify_swap(<2 x i1> %b, <2 x i8> %a) {
+; CHECK-LABEL: @add_select_sub_both_arms_simplify_swap(
+; CHECK-NEXT: [[ADD:%.*]] = select <2 x i1> [[B:%.*]], <2 x i8> <i8 42, i8 99>, <2 x i8> [[A:%.*]]
+; CHECK-NEXT: ret <2 x i8> [[ADD]]
+;
+ %sub = sub <2 x i8> <i8 42, i8 99>, %a
+ %sel = select <2 x i1> %b, <2 x i8> %sub, <2 x i8> zeroinitializer
+ %add = add <2 x i8> %sel, %a
+ ret <2 x i8> %add
+}
+
+define i8 @add_select_sub_both_arms_simplify_use1(i1 %b, i8 %a) {
+; CHECK-LABEL: @add_select_sub_both_arms_simplify_use1(
+; CHECK-NEXT: [[SUB:%.*]] = sub i8 42, [[A:%.*]]
+; CHECK-NEXT: call void @use(i8 [[SUB]])
+; CHECK-NEXT: [[ADD:%.*]] = select i1 [[B:%.*]], i8 [[A]], i8 42
+; CHECK-NEXT: ret i8 [[ADD]]
+;
+ %sub = sub i8 42, %a
+ call void @use(i8 %sub)
+ %sel = select i1 %b, i8 0, i8 %sub
+ %add = add i8 %sel, %a
+ ret i8 %add
+}
+
+define i8 @add_select_sub_both_arms_simplify_use2(i1 %b, i8 %a) {
+; CHECK-LABEL: @add_select_sub_both_arms_simplify_use2(
+; CHECK-NEXT: [[SUB:%.*]] = sub i8 42, [[A:%.*]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[B:%.*]], i8 0, i8 [[SUB]]
+; CHECK-NEXT: call void @use(i8 [[SEL]])
+; CHECK-NEXT: [[ADD:%.*]] = add i8 [[SEL]], [[A]]
+; CHECK-NEXT: ret i8 [[ADD]]
+;
+ %sub = sub i8 42, %a
+ %sel = select i1 %b, i8 0, i8 %sub
+ call void @use(i8 %sel)
+ %add = add i8 %sel, %a
+ ret i8 %add
+}
More information about the llvm-commits
mailing list