[llvm] 377da51 - [InstCombine] Add test for detecting `(x ^ -x)` as a ~Mask; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 11:26:47 PDT 2024
Author: Noah Goldstein
Date: 2024-03-12T13:26:18-05:00
New Revision: 377da51546b2f514c3e90fca351004a2cf3f1eed
URL: https://github.com/llvm/llvm-project/commit/377da51546b2f514c3e90fca351004a2cf3f1eed
DIFF: https://github.com/llvm/llvm-project/commit/377da51546b2f514c3e90fca351004a2cf3f1eed.diff
LOG: [InstCombine] Add test for detecting `(x ^ -x)` as a ~Mask; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-and-lowbit-mask.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-and-lowbit-mask.ll b/llvm/test/Transforms/InstCombine/icmp-and-lowbit-mask.ll
index 640a95b0561602..903d70685ab531 100644
--- a/llvm/test/Transforms/InstCombine/icmp-and-lowbit-mask.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-and-lowbit-mask.ll
@@ -453,6 +453,25 @@ define i1 @src_is_notmask_shl(i8 %x_in, i8 %y, i1 %cond) {
ret i1 %r
}
+define i1 @src_is_notmask_x_xor_neg_x(i8 %x_in, i8 %y, i1 %cond) {
+; CHECK-LABEL: @src_is_notmask_x_xor_neg_x(
+; CHECK-NEXT: [[X:%.*]] = xor i8 [[X_IN:%.*]], 123
+; CHECK-NEXT: [[NEG_Y:%.*]] = sub i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[NOTMASK0:%.*]] = xor i8 [[NEG_Y]], [[Y]]
+; CHECK-NEXT: [[NOTMASK:%.*]] = select i1 [[COND:%.*]], i8 [[NOTMASK0]], i8 -8
+; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], [[NOTMASK]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 0
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %x = xor i8 %x_in, 123
+ %neg_y = sub i8 0, %y
+ %nmask0 = xor i8 %y, %neg_y
+ %notmask = select i1 %cond, i8 %nmask0, i8 -8
+ %and = and i8 %x, %notmask
+ %r = icmp eq i8 %and, 0
+ ret i1 %r
+}
+
define i1 @src_is_notmask_shl_fail_multiuse_invert(i8 %x_in, i8 %y, i1 %cond) {
; CHECK-LABEL: @src_is_notmask_shl_fail_multiuse_invert(
; CHECK-NEXT: [[X:%.*]] = xor i8 [[X_IN:%.*]], 122
More information about the llvm-commits
mailing list