diff options
Diffstat (limited to 'llvm/test/Transforms/InstCombine/icmp.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 623f401b718..1f97009911b 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -2427,9 +2427,9 @@ define i1 @icmp_and_or_lshr(i32 %x, i32 %y) { define <2 x i1> @icmp_and_or_lshr_vec(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @icmp_and_or_lshr_vec( -; CHECK-NEXT: [[SHF1:%.*]] = shl nuw <2 x i32> <i32 1, i32 1>, %y +; CHECK-NEXT: [[SHF1:%.*]] = shl nuw <2 x i32> <i32 1, i32 1>, [[Y:%.*]] ; CHECK-NEXT: [[OR2:%.*]] = or <2 x i32> [[SHF1]], <i32 1, i32 1> -; CHECK-NEXT: [[AND3:%.*]] = and <2 x i32> [[OR2]], %x +; CHECK-NEXT: [[AND3:%.*]] = and <2 x i32> [[OR2]], [[X:%.*]] ; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND3]], zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[RET]] ; @@ -2440,6 +2440,23 @@ define <2 x i1> @icmp_and_or_lshr_vec(<2 x i32> %x, <2 x i32> %y) { ret <2 x i1> %ret } +define <2 x i1> @icmp_and_or_lshr_vec_commute(<2 x i32> %xp, <2 x i32> %y) { +; CHECK-LABEL: @icmp_and_or_lshr_vec_commute( +; CHECK-NEXT: [[X:%.*]] = srem <2 x i32> [[XP:%.*]], <i32 42, i32 42> +; CHECK-NEXT: [[SHF:%.*]] = lshr <2 x i32> [[X]], [[Y:%.*]] +; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[X]], [[SHF]] +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], <i32 1, i32 1> +; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[RET]] +; + %x = srem <2 x i32> %xp, <i32 42, i32 -42> ; prevent complexity-based canonicalization + %shf = lshr <2 x i32> %x, %y + %or = or <2 x i32> %x, %shf + %and = and <2 x i32> %or, <i32 1, i32 1> + %ret = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %ret +} + define i1 @icmp_and_or_lshr_cst(i32 %x) { ; CHECK-LABEL: @icmp_and_or_lshr_cst( ; CHECK-NEXT: [[AND1:%.*]] = and i32 %x, 3 @@ -2455,7 +2472,7 @@ define i1 @icmp_and_or_lshr_cst(i32 %x) { define <2 x i1> @icmp_and_or_lshr_cst_vec(<2 x i32> %x) { ; CHECK-LABEL: @icmp_and_or_lshr_cst_vec( -; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> %x, <i32 3, i32 3> +; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> [[X:%.*]], <i32 3, i32 3> ; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND1]], zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[RET]] ; @@ -2466,6 +2483,23 @@ define <2 x i1> @icmp_and_or_lshr_cst_vec(<2 x i32> %x) { ret <2 x i1> %ret } +define <2 x i1> @icmp_and_or_lshr_cst_vec_commute(<2 x i32> %xp) { +; CHECK-LABEL: @icmp_and_or_lshr_cst_vec_commute( +; CHECK-NEXT: [[X:%.*]] = srem <2 x i32> [[XP:%.*]], <i32 42, i32 42> +; CHECK-NEXT: [[SHF:%.*]] = lshr <2 x i32> [[X]], <i32 1, i32 1> +; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[X]], [[SHF]] +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], <i32 1, i32 1> +; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[RET]] +; + %x = srem <2 x i32> %xp, <i32 42, i32 -42> ; prevent complexity-based canonicalization + %shf = lshr <2 x i32> %x, <i32 1, i32 1> + %or = or <2 x i32> %x, %shf + %and = and <2 x i32> %or, <i32 1, i32 1> + %ret = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %ret +} + define i1 @shl_ap1_zero_ap2_non_zero_2(i32 %a) { ; CHECK-LABEL: @shl_ap1_zero_ap2_non_zero_2( ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 %a, 29 |