From e99c07a30e2d8d5010bffdfdc14903c93a8e132d Mon Sep 17 00:00:00 2001 From: Chenbing Zheng Date: Tue, 14 Jun 2022 11:02:18 +0800 Subject: [PATCH] [InstCombine] add tests for compare-signs --- .../Transforms/InstCombine/compare-signs.ll | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/compare-signs.ll b/llvm/test/Transforms/InstCombine/compare-signs.ll index 620a508b2b51..7b56a7b7bde3 100644 --- a/llvm/test/Transforms/InstCombine/compare-signs.ll +++ b/llvm/test/Transforms/InstCombine/compare-signs.ll @@ -63,6 +63,68 @@ define <2 x i32> @test3vec(<2 x i32> %a, <2 x i32> %b) nounwind readnone { ret <2 x i32> %t3 } +define <2 x i32> @test3vec_undef1(<2 x i32> %a, <2 x i32> %b) nounwind readnone { +; CHECK-LABEL: @test3vec_undef1( +; CHECK-NEXT: [[T0:%.*]] = lshr <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[T1:%.*]] = lshr <2 x i32> [[B:%.*]], +; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T0]], [[T1]] +; CHECK-NEXT: [[T3:%.*]] = zext <2 x i1> [[T2]] to <2 x i32> +; CHECK-NEXT: ret <2 x i32> [[T3]] +; + %t0 = lshr <2 x i32> %a, + %t1 = lshr <2 x i32> %b, + %t2 = icmp eq <2 x i32> %t0, %t1 + %t3 = zext <2 x i1> %t2 to <2 x i32> + ret <2 x i32> %t3 +} + +define <2 x i32> @test3vec_undef2(<2 x i32> %a, <2 x i32> %b) nounwind readnone { +; CHECK-LABEL: @test3vec_undef2( +; CHECK-NEXT: [[T0:%.*]] = lshr <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[T1:%.*]] = lshr <2 x i32> [[B:%.*]], +; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T0]], [[T1]] +; CHECK-NEXT: [[T3:%.*]] = zext <2 x i1> [[T2]] to <2 x i32> +; CHECK-NEXT: ret <2 x i32> [[T3]] +; + %t0 = lshr <2 x i32> %a, + %t1 = lshr <2 x i32> %b, + %t2 = icmp eq <2 x i32> %t0, %t1 + %t3 = zext <2 x i1> %t2 to <2 x i32> + ret <2 x i32> %t3 +} + +; negative test + +define <2 x i32> @test3vec_diff(<2 x i32> %a, <2 x i32> %b) nounwind readnone { +; CHECK-LABEL: @test3vec_diff( +; CHECK-NEXT: [[T0:%.*]] = lshr <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[T1:%.*]] = lshr <2 x i32> [[B:%.*]], +; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T0]], [[T1]] +; CHECK-NEXT: [[T3:%.*]] = zext <2 x i1> [[T2]] to <2 x i32> +; CHECK-NEXT: ret <2 x i32> [[T3]] +; + %t0 = lshr <2 x i32> %a, + %t1 = lshr <2 x i32> %b, + %t2 = icmp eq <2 x i32> %t0, %t1 + %t3 = zext <2 x i1> %t2 to <2 x i32> + ret <2 x i32> %t3 +} + +define <2 x i32> @test3vec_non-uniform(<2 x i32> %a, <2 x i32> %b) nounwind readnone { +; CHECK-LABEL: @test3vec_non-uniform( +; CHECK-NEXT: [[T0:%.*]] = lshr <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[T1:%.*]] = lshr <2 x i32> [[B:%.*]], +; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T0]], [[T1]] +; CHECK-NEXT: [[T3:%.*]] = zext <2 x i1> [[T2]] to <2 x i32> +; CHECK-NEXT: ret <2 x i32> [[T3]] +; + %t0 = lshr <2 x i32> %a, + %t1 = lshr <2 x i32> %b, + %t2 = icmp eq <2 x i32> %t0, %t1 + %t3 = zext <2 x i1> %t2 to <2 x i32> + ret <2 x i32> %t3 +} + ; Variation on @test3: checking the 2nd bit in a situation where the 5th bit ; is one, not zero. define i32 @test3i(i32 %a, i32 %b) nounwind readnone {