diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2024-04-22 16:01:03 -0500 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2024-05-03 14:10:24 -0500 |
commit | 1708788d2d1091d1663cd859c5913121463a6b73 (patch) | |
tree | 72e471fc046d391fa146ff574bd3cc7be4bad86e | |
parent | d8428dfeb8d9a0bbb5345f96f29a4a66eb950769 (diff) |
[InstCombine] Add non-splat test for `(icmp (lshr x, y), x)`; NFC
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-div-constant.ll | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll index b047715432d7..d815e093a33f 100644 --- a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll +++ b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll @@ -118,8 +118,8 @@ define i32 @icmp_div(i16 %a, i16 %c) { ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i16 [[A:%.*]], 0 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[THEN:%.*]], label [[EXIT:%.*]] ; CHECK: then: -; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[C:%.*]], 0 -; CHECK-NEXT: [[TMP0:%.*]] = sext i1 [[CMP]] to i32 +; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq i16 [[C:%.*]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = sext i1 [[CMP_NOT]] to i32 ; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[TMP0]], [[THEN]] ] @@ -173,8 +173,8 @@ define i32 @icmp_div3(i16 %a, i16 %c) { ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i16 [[A:%.*]], 0 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[THEN:%.*]], label [[EXIT:%.*]] ; CHECK: then: -; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[C:%.*]], 0 -; CHECK-NEXT: [[TMP0:%.*]] = sext i1 [[CMP]] to i32 +; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq i16 [[C:%.*]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = sext i1 [[CMP_NOT]] to i32 ; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ -1, [[ENTRY:%.*]] ], [ [[TMP0]], [[THEN]] ] @@ -381,8 +381,8 @@ define i1 @sdiv_eq_smin_use(i32 %x, i32 %y) { define i1 @sdiv_x_by_const_cmp_x(i32 %x) { ; CHECK-LABEL: @sdiv_x_by_const_cmp_x( -; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0 -; CHECK-NEXT: ret i1 [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[X:%.*]], 0 +; CHECK-NEXT: ret i1 [[R]] ; %v = sdiv i32 %x, 13 %r = icmp eq i32 %v, %x @@ -399,12 +399,35 @@ define i1 @udiv_x_by_const_cmp_x(i32 %x) { ret i1 %2 } +define <2 x i1> @udiv_x_by_const_cmp_x_non_splat(<2 x i32> %x) { +; CHECK-LABEL: @udiv_x_by_const_cmp_x_non_splat( +; CHECK-NEXT: [[TMP1:%.*]] = udiv <2 x i32> [[X:%.*]], <i32 123, i32 -123> +; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[TMP1]], [[X]] +; CHECK-NEXT: ret <2 x i1> [[TMP2]] +; + %1 = udiv <2 x i32> %x, <i32 123, i32 -123> + %2 = icmp slt <2 x i32> %1, %x + ret <2 x i1> %2 +} + + +define <2 x i1> @sdiv_x_by_const_cmp_x_non_splat(<2 x i32> %x) { +; CHECK-LABEL: @sdiv_x_by_const_cmp_x_non_splat( +; CHECK-NEXT: [[TMP1:%.*]] = sdiv <2 x i32> [[X:%.*]], <i32 2, i32 3> +; CHECK-NEXT: [[TMP2:%.*]] = icmp eq <2 x i32> [[TMP1]], [[X]] +; CHECK-NEXT: ret <2 x i1> [[TMP2]] +; + %1 = sdiv <2 x i32> %x, <i32 2, i32 3> + %2 = icmp eq <2 x i32> %1, %x + ret <2 x i1> %2 +} + ; Same as above but with right shift instead of division (C != 0) define i1 @lshr_x_by_const_cmp_x(i32 %x) { ; CHECK-LABEL: @lshr_x_by_const_cmp_x( -; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 0 -; CHECK-NEXT: ret i1 [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[X:%.*]], 0 +; CHECK-NEXT: ret i1 [[R]] ; %v = lshr i32 %x, 1 %r = icmp eq i32 %v, %x @@ -421,6 +444,30 @@ define <4 x i1> @lshr_by_const_cmp_sle_value(<4 x i32> %x) { ret <4 x i1> %r } +define <4 x i1> @lshr_by_const_cmp_sle_value_non_splat(<4 x i32> %x) { +; CHECK-LABEL: @lshr_by_const_cmp_sle_value_non_splat( +; CHECK-NEXT: [[V:%.*]] = lshr <4 x i32> [[X:%.*]], <i32 3, i32 3, i32 3, i32 5> +; CHECK-NEXT: [[R:%.*]] = icmp sle <4 x i32> [[V]], [[X]] +; CHECK-NEXT: ret <4 x i1> [[R]] +; + %v = lshr <4 x i32> %x, <i32 3, i32 3, i32 3, i32 5> + %r = icmp sle <4 x i32> %v, %x + ret <4 x i1> %r +} + + +define <4 x i1> @ashr_by_const_cmp_sge_value_non_splat(<4 x i32> %x) { +; CHECK-LABEL: @ashr_by_const_cmp_sge_value_non_splat( +; CHECK-NEXT: [[V:%.*]] = ashr <4 x i32> [[X:%.*]], <i32 1, i32 2, i32 3, i32 4> +; CHECK-NEXT: [[R:%.*]] = icmp sge <4 x i32> [[V]], [[X]] +; CHECK-NEXT: ret <4 x i1> [[R]] +; + %v = ashr <4 x i32> %x, <i32 1, i32 2, i32 3, i32 4> + %r = icmp sge <4 x i32> %v, %x + ret <4 x i1> %r +} + + define i1 @lshr_by_const_cmp_sge_value(i32 %x) { ; CHECK-LABEL: @lshr_by_const_cmp_sge_value( ; CHECK-NEXT: [[R:%.*]] = icmp slt i32 [[X:%.*]], 1 |