[llvm] 5542bbf - [InstSimplify] add tests for logical-and/or reduction; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 14:36:49 PST 2023
Author: Sanjay Patel
Date: 2023-01-20T17:35:24-05:00
New Revision: 5542bbf250b0dbf0fe74c45330a3cd86dd86ca86
URL: https://github.com/llvm/llvm-project/commit/5542bbf250b0dbf0fe74c45330a3cd86dd86ca86
DIFF: https://github.com/llvm/llvm-project/commit/5542bbf250b0dbf0fe74c45330a3cd86dd86ca86.diff
LOG: [InstSimplify] add tests for logical-and/or reduction; NFC
issue #60167
Added:
Modified:
llvm/test/Transforms/InstSimplify/select-logical.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/select-logical.ll b/llvm/test/Transforms/InstSimplify/select-logical.ll
index 09109eb1c4fe5..4819ade6ae44e 100644
--- a/llvm/test/Transforms/InstSimplify/select-logical.ll
+++ b/llvm/test/Transforms/InstSimplify/select-logical.ll
@@ -585,3 +585,58 @@ define i1 @always_false_same_op(i1 %x) {
%r = select i1 %x, i1 false, i1 %x
ret i1 %r
}
+
+define i1 @or_and_common_op_commute0(i1 %x, i1 %y) {
+; CHECK-LABEL: @or_and_common_op_commute0(
+; CHECK-NEXT: [[A:%.*]] = select i1 [[X:%.*]], i1 [[Y:%.*]], i1 false
+; CHECK-NEXT: [[R:%.*]] = select i1 [[A]], i1 true, i1 [[Y]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %a = select i1 %x, i1 %y, i1 false
+ %r = select i1 %a, i1 true, i1 %y
+ ret i1 %r
+}
+
+define <2 x i1> @or_and_common_op_commute1(<2 x i1> %x, <2 x i1> %y) {
+; CHECK-LABEL: @or_and_common_op_commute1(
+; CHECK-NEXT: [[A:%.*]] = select <2 x i1> [[Y:%.*]], <2 x i1> [[X:%.*]], <2 x i1> zeroinitializer
+; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[A]], <2 x i1> <i1 true, i1 true>, <2 x i1> [[Y]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %a = select <2 x i1> %y, <2 x i1> %x, <2 x i1> zeroinitializer
+ %r = select <2 x i1> %a, <2 x i1> <i1 true, i1 true>, <2 x i1> %y
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @or_and_common_op_commute2(<2 x i1> %x, <2 x i1> %y) {
+; CHECK-LABEL: @or_and_common_op_commute2(
+; CHECK-NEXT: [[A:%.*]] = select <2 x i1> [[X:%.*]], <2 x i1> [[Y:%.*]], <2 x i1> <i1 false, i1 poison>
+; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[Y]], <2 x i1> <i1 true, i1 true>, <2 x i1> [[A]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %a = select <2 x i1> %x, <2 x i1> %y, <2 x i1> <i1 0, i1 poison>
+ %r = select <2 x i1> %y, <2 x i1> <i1 true, i1 true>, <2 x i1> %a
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @or_and_common_op_commute3(<2 x i1> %x, <2 x i1> %y) {
+; CHECK-LABEL: @or_and_common_op_commute3(
+; CHECK-NEXT: [[A:%.*]] = select <2 x i1> [[Y:%.*]], <2 x i1> [[X:%.*]], <2 x i1> zeroinitializer
+; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[Y]], <2 x i1> <i1 poison, i1 true>, <2 x i1> [[A]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %a = select <2 x i1> %y, <2 x i1> %x, <2 x i1> zeroinitializer
+ %r = select <2 x i1> %y, <2 x i1> <i1 poison, i1 true>, <2 x i1> %a
+ ret <2 x i1> %r
+}
+
+define i1 @or_and_not_common_op(i1 %x, i1 %y, i1 %z) {
+; CHECK-LABEL: @or_and_not_common_op(
+; CHECK-NEXT: [[A:%.*]] = select i1 [[X:%.*]], i1 [[Y:%.*]], i1 false
+; CHECK-NEXT: [[R:%.*]] = select i1 [[A]], i1 true, i1 [[Z:%.*]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %a = select i1 %x, i1 %y, i1 false
+ %r = select i1 %a, i1 true, i1 %z
+ ret i1 %r
+}
More information about the llvm-commits
mailing list