From: Sanjay Patel Date: Fri, 3 Feb 2017 20:56:38 +0000 (+0000) Subject: [InstCombine] auto-generate better test checks; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=482cfedce18c2a5983e267e31ac39182226291f9;p=llvm [InstCombine] auto-generate better test checks; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294040 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/pr19420.ll b/test/Transforms/InstCombine/pr19420.ll index 23fa0a40974..015f35eaaa5 100644 --- a/test/Transforms/InstCombine/pr19420.ll +++ b/test/Transforms/InstCombine/pr19420.ll @@ -1,36 +1,44 @@ ; RUN: opt -S -instcombine < %s | FileCheck %s -; CHECK-LABEL: @test_FoldShiftByConstant_CreateSHL -; CHECK: mul <4 x i32> %in, -; CHECK-NEXT: ret define <4 x i32> @test_FoldShiftByConstant_CreateSHL(<4 x i32> %in) { +; CHECK-LABEL: @test_FoldShiftByConstant_CreateSHL( +; CHECK-NEXT: [[VSHL_N:%.*]] = mul <4 x i32> %in, +; CHECK-NEXT: ret <4 x i32> [[VSHL_N]] +; %mul.i = mul <4 x i32> %in, %vshl_n = shl <4 x i32> %mul.i, ret <4 x i32> %vshl_n } -; CHECK-LABEL: @test_FoldShiftByConstant_CreateSHL2 -; CHECK: mul <8 x i16> %in, -; CHECK-NEXT: ret define <8 x i16> @test_FoldShiftByConstant_CreateSHL2(<8 x i16> %in) { +; CHECK-LABEL: @test_FoldShiftByConstant_CreateSHL2( +; CHECK-NEXT: [[VSHL_N:%.*]] = mul <8 x i16> %in, +; CHECK-NEXT: ret <8 x i16> [[VSHL_N]] +; %mul.i = mul <8 x i16> %in, %vshl_n = shl <8 x i16> %mul.i, ret <8 x i16> %vshl_n } -; CHECK-LABEL: @test_FoldShiftByConstant_CreateAnd -; CHECK: mul <16 x i8> %in0, -; CHECK-NEXT: and <16 x i8> %vsra_n2, -; CHECK-NEXT: ret define <16 x i8> @test_FoldShiftByConstant_CreateAnd(<16 x i8> %in0) { +; CHECK-LABEL: @test_FoldShiftByConstant_CreateAnd( +; CHECK-NEXT: [[VSRA_N2:%.*]] = mul <16 x i8> %in0, +; CHECK-NEXT: [[VSHL_N:%.*]] = and <16 x i8> [[VSRA_N2]], +; CHECK-NEXT: ret <16 x i8> [[VSHL_N]] +; %vsra_n = ashr <16 x i8> %in0, %tmp = add <16 x i8> %in0, %vsra_n %vshl_n = shl <16 x i8> %tmp, ret <16 x i8> %vshl_n } - define i32 @bar(i32 %x, i32 %y) { +; CHECK-LABEL: @bar( +; CHECK-NEXT: [[B1:%.*]] = shl i32 %y, 4 +; CHECK-NEXT: [[A2:%.*]] = add i32 [[B1]], %x +; CHECK-NEXT: [[C:%.*]] = and i32 [[A2]], -16 +; CHECK-NEXT: ret i32 [[C]] +; %a = lshr i32 %x, 4 %b = add i32 %a, %y %c = shl i32 %b, 4 @@ -38,16 +46,25 @@ define i32 @bar(i32 %x, i32 %y) { } define <2 x i32> @bar_v2i32(<2 x i32> %x, <2 x i32> %y) { +; CHECK-LABEL: @bar_v2i32( +; CHECK-NEXT: [[B1:%.*]] = shl <2 x i32> %y, +; CHECK-NEXT: [[A2:%.*]] = add <2 x i32> [[B1]], %x +; CHECK-NEXT: [[C:%.*]] = and <2 x i32> [[A2]], +; CHECK-NEXT: ret <2 x i32> [[C]] +; %a = lshr <2 x i32> %x, %b = add <2 x i32> %a, %y %c = shl <2 x i32> %b, ret <2 x i32> %c } - - - define i32 @foo(i32 %x, i32 %y) { +; CHECK-LABEL: @foo( +; CHECK-NEXT: [[C1:%.*]] = shl i32 %y, 4 +; CHECK-NEXT: [[X_MASK:%.*]] = and i32 %x, 128 +; CHECK-NEXT: [[D:%.*]] = add i32 [[X_MASK]], [[C1]] +; CHECK-NEXT: ret i32 [[D]] +; %a = lshr i32 %x, 4 %b = and i32 %a, 8 %c = add i32 %b, %y @@ -56,6 +73,13 @@ define i32 @foo(i32 %x, i32 %y) { } define <2 x i32> @foo_v2i32(<2 x i32> %x, <2 x i32> %y) { +; CHECK-LABEL: @foo_v2i32( +; CHECK-NEXT: [[A:%.*]] = lshr <2 x i32> %x, +; CHECK-NEXT: [[B:%.*]] = and <2 x i32> [[A]], +; CHECK-NEXT: [[C:%.*]] = add <2 x i32> [[B]], %y +; CHECK-NEXT: [[D:%.*]] = shl <2 x i32> [[C]], +; CHECK-NEXT: ret <2 x i32> [[D]] +; %a = lshr <2 x i32> %x, %b = and <2 x i32> %a, %c = add <2 x i32> %b, %y @@ -63,5 +87,3 @@ define <2 x i32> @foo_v2i32(<2 x i32> %x, <2 x i32> %y) { ret <2 x i32> %d } - -