[llvm] a56a02b - [InstSimplify] add commuted variants of logical and/or pattern; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 26 10:42:51 PST 2023
Author: Sanjay Patel
Date: 2023-01-26T13:38:43-05:00
New Revision: a56a02bc7eda421bb43db4936e70ba7f3362ccbc
URL: https://github.com/llvm/llvm-project/commit/a56a02bc7eda421bb43db4936e70ba7f3362ccbc
DIFF: https://github.com/llvm/llvm-project/commit/a56a02bc7eda421bb43db4936e70ba7f3362ccbc.diff
LOG: [InstSimplify] add commuted variants of logical and/or pattern; NFC
Existing tests were added with D138853, but that patch failed
to handle all of the commutes. The poison-safety behavior is
symmetric, so I'm not duplicating all of the tests that were
added with that patch.
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 b0fc8678ca14d..0fa9c68ac6d24 100644
--- a/llvm/test/Transforms/InstSimplify/select-logical.ll
+++ b/llvm/test/Transforms/InstSimplify/select-logical.ll
@@ -184,7 +184,6 @@ define i1 @logical_or_not_and(i1 %x, i1 %y) {
ret i1 %r
}
-
; !(X || Y) && Y --> false
define i1 @logical_or_not_and_commute_or(i1 %x, i1 %y) {
@@ -197,6 +196,36 @@ define i1 @logical_or_not_and_commute_or(i1 %x, i1 %y) {
ret i1 %r
}
+; X && !(X || Y) --> false
+
+define i1 @logical_or_not_commute_and(i1 %x, i1 %y) {
+; CHECK-LABEL: @logical_or_not_commute_and(
+; CHECK-NEXT: [[L_AND:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[Y:%.*]]
+; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[L_AND]], true
+; CHECK-NEXT: [[R:%.*]] = select i1 [[X]], i1 [[NOT]], i1 false
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %l.and = select i1 %x, i1 true, i1 %y
+ %not = xor i1 %l.and, true
+ %r = select i1 %x, i1 %not, i1 false
+ ret i1 %r
+}
+
+; Y && !(X || Y) --> false
+
+define i1 @logical_or_not_commute_and_commute_or(i1 %x, i1 %y) {
+; CHECK-LABEL: @logical_or_not_commute_and_commute_or(
+; CHECK-NEXT: [[L_AND:%.*]] = select i1 [[X:%.*]], i1 true, i1 [[Y:%.*]]
+; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[L_AND]], true
+; CHECK-NEXT: [[R:%.*]] = select i1 [[Y]], i1 [[NOT]], i1 false
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %l.and = select i1 %x, i1 true, i1 %y
+ %not = xor i1 %l.and, true
+ %r = select i1 %y, i1 %not, i1 false
+ ret i1 %r
+}
+
; vector case !(X || Y) && X --> false
define <3 x i1> @logical_or_not_and_vector1(<3 x i1> %x, <3 x i1> %y) {
More information about the llvm-commits
mailing list