[llvm] 8a28b9b - [ValueTracking] Add tests for `insertelement` in `isKnownNonZero`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 11:14:00 PDT 2024
Author: Noah Goldstein
Date: 2024-04-10T13:13:43-05:00
New Revision: 8a28b9b8ec1686426a4b43c8431570eaa1da77d9
URL: https://github.com/llvm/llvm-project/commit/8a28b9b8ec1686426a4b43c8431570eaa1da77d9
DIFF: https://github.com/llvm/llvm-project/commit/8a28b9b8ec1686426a4b43c8431570eaa1da77d9.diff
LOG: [ValueTracking] Add tests for `insertelement` in `isKnownNonZero`; NFC
Added:
Modified:
llvm/test/Transforms/InstSimplify/known-non-zero.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/known-non-zero.ll b/llvm/test/Transforms/InstSimplify/known-non-zero.ll
index c443dc68d0c13f..1417e86ee678c8 100644
--- a/llvm/test/Transforms/InstSimplify/known-non-zero.ll
+++ b/llvm/test/Transforms/InstSimplify/known-non-zero.ll
@@ -293,3 +293,99 @@ define <4 x i1> @shuf_nonzero_rhs2_fail(<4 x i8> %xx) {
%r = icmp eq <4 x i8> %shuf, zeroinitializer
ret <4 x i1> %r
}
+
+define <2 x i1> @insert_nonzero0(<2 x i8> %xx, i8 %yy) {
+; CHECK-LABEL: @insert_nonzero0(
+; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 0>
+; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 1
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x = add nuw <2 x i8> %xx, <i8 1, i8 0>
+ %y = add nuw i8 %yy, 1
+
+ %ins = insertelement <2 x i8> %x, i8 %y, i32 1
+ %r = icmp eq <2 x i8> %ins, zeroinitializer
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @insert_nonzero1(<2 x i8> %xx, i8 %yy) {
+; CHECK-LABEL: @insert_nonzero1(
+; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 0, i8 1>
+; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 0
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x = add nuw <2 x i8> %xx, <i8 0, i8 1>
+ %y = add nuw i8 %yy, 1
+
+ %ins = insertelement <2 x i8> %x, i8 %y, i32 0
+ %r = icmp eq <2 x i8> %ins, zeroinitializer
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @insert_nonzero_fail(<2 x i8> %xx, i8 %yy) {
+; CHECK-LABEL: @insert_nonzero_fail(
+; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 0>
+; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 0
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x = add nuw <2 x i8> %xx, <i8 1, i8 0>
+ %y = add nuw i8 %yy, 1
+
+ %ins = insertelement <2 x i8> %x, i8 %y, i32 0
+ %r = icmp eq <2 x i8> %ins, zeroinitializer
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @insert_nonzero_fail2(<2 x i8> %xx, i8 %yy) {
+; CHECK-LABEL: @insert_nonzero_fail2(
+; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 0, i8 1>
+; CHECK-NEXT: [[Y:%.*]] = add i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 0
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x = add nuw <2 x i8> %xx, <i8 0, i8 1>
+ %y = add i8 %yy, 1
+
+ %ins = insertelement <2 x i8> %x, i8 %y, i32 0
+ %r = icmp eq <2 x i8> %ins, zeroinitializer
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @insert_nonzero_any_idx(<2 x i8> %xx, i8 %yy, i32 %idx) {
+; CHECK-LABEL: @insert_nonzero_any_idx(
+; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 1>
+; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 [[IDX:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x = add nuw <2 x i8> %xx, <i8 1, i8 1>
+ %y = add nuw i8 %yy, 1
+
+ %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
+ %r = icmp eq <2 x i8> %ins, zeroinitializer
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @insert_nonzero_any_idx_fail(<2 x i8> %xx, i8 %yy, i32 %idx) {
+; CHECK-LABEL: @insert_nonzero_any_idx_fail(
+; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 0>
+; CHECK-NEXT: [[Y:%.*]] = add nuw i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 [[IDX:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[INS]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %x = add nuw <2 x i8> %xx, <i8 1, i8 0>
+ %y = add nuw i8 %yy, 1
+
+ %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
+ %r = icmp eq <2 x i8> %ins, zeroinitializer
+ ret <2 x i1> %r
+}
More information about the llvm-commits
mailing list