From db400baa80307ebcd07b6c6e4095f3cb2f5ab41d Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 12 Sep 2016 15:51:42 +0000 Subject: [PATCH] [InstCombine] add tests to show missing vector folds llvm-svn: 281219 --- llvm/test/Transforms/InstCombine/exact.ll | 18 +++++++++++++++++- llvm/test/Transforms/InstCombine/shift.ll | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/llvm/test/Transforms/InstCombine/exact.ll b/llvm/test/Transforms/InstCombine/exact.ll index 3d1e1e4..070dfd3 100644 --- a/llvm/test/Transforms/InstCombine/exact.ll +++ b/llvm/test/Transforms/InstCombine/exact.ll @@ -132,7 +132,7 @@ define <2 x i1> @ashr_icmp2_vec(<2 x i64> %X) { ; PR9998 ; Make sure we don't transform the ashr here into an sdiv -define i1 @pr9998(i32 %V) nounwind { +define i1 @pr9998(i32 %V) { ; CHECK-LABEL: @pr9998( ; CHECK-NEXT: [[W_MASK:%.*]] = and i32 %V, 1 ; CHECK-NEXT: [[Z:%.*]] = icmp ne i32 [[W_MASK]], 0 @@ -145,6 +145,22 @@ define i1 @pr9998(i32 %V) nounwind { ret i1 %Z } +; FIXME: Vectors should fold the same way. +define <2 x i1> @pr9998vec(<2 x i32> %V) { +; CHECK-LABEL: @pr9998vec( +; CHECK-NEXT: [[W:%.*]] = shl <2 x i32> %V, +; CHECK-NEXT: [[X:%.*]] = ashr exact <2 x i32> [[W]], +; CHECK-NEXT: [[Y:%.*]] = sext <2 x i32> [[X]] to <2 x i64> +; CHECK-NEXT: [[Z:%.*]] = icmp ugt <2 x i64> [[Y]], +; CHECK-NEXT: ret <2 x i1> [[Z]] +; + %W = shl <2 x i32> %V, + %X = ashr exact <2 x i32> %W, + %Y = sext <2 x i32> %X to <2 x i64> + %Z = icmp ugt <2 x i64> %Y, + ret <2 x i1> %Z +} + define i1 @udiv_icmp1(i64 %X) { ; CHECK-LABEL: @udiv_icmp1( ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i64 %X, 0 diff --git a/llvm/test/Transforms/InstCombine/shift.ll b/llvm/test/Transforms/InstCombine/shift.ll index 4629506..12ab353 100644 --- a/llvm/test/Transforms/InstCombine/shift.ll +++ b/llvm/test/Transforms/InstCombine/shift.ll @@ -628,6 +628,18 @@ define i1 @test35(i32 %X) { ret i1 %tmp2 } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test35vec(<2 x i32> %X) { +; CHECK-LABEL: @test35vec( +; CHECK-NEXT: [[TMP1:%.*]] = ashr <2 x i32> %X, +; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[TMP1]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[TMP2]] +; + %tmp1 = ashr <2 x i32> %X, + %tmp2 = icmp slt <2 x i32> %tmp1, zeroinitializer + ret <2 x i1> %tmp2 +} + define i128 @test36(i128 %A, i128 %B) { ; CHECK-LABEL: @test36( ; CHECK-NEXT: entry: -- 2.7.4