From f99ef5455aad014eaf43278f59544619e558ecad Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 26 Jan 2020 17:27:53 +0000 Subject: [PATCH] [InstCombine] Add extra shift(c1,add(c2,y)) tests for PR15141 --- llvm/test/Transforms/InstCombine/shift-add.ll | 61 +++++++++++++++++-- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/shift-add.ll b/llvm/test/Transforms/InstCombine/shift-add.ll index 497159f19b64..dd34233f7a47 100644 --- a/llvm/test/Transforms/InstCombine/shift-add.ll +++ b/llvm/test/Transforms/InstCombine/shift-add.ll @@ -5,7 +5,7 @@ define i32 @shl_C1_add_A_C2_i32(i16 %A) { ; CHECK-LABEL: @shl_C1_add_A_C2_i32( -; CHECK-NEXT: [[B:%.*]] = zext i16 %A to i32 +; CHECK-NEXT: [[B:%.*]] = zext i16 [[A:%.*]] to i32 ; CHECK-NEXT: [[D:%.*]] = shl i32 192, [[B]] ; CHECK-NEXT: ret i32 [[D]] ; @@ -27,7 +27,7 @@ define i32 @ashr_C1_add_A_C2_i32(i32 %A) { define i32 @lshr_C1_add_A_C2_i32(i32 %A) { ; CHECK-LABEL: @lshr_C1_add_A_C2_i32( -; CHECK-NEXT: [[B:%.*]] = and i32 %A, 65535 +; CHECK-NEXT: [[B:%.*]] = and i32 [[A:%.*]], 65535 ; CHECK-NEXT: [[D:%.*]] = shl i32 192, [[B]] ; CHECK-NEXT: ret i32 [[D]] ; @@ -39,7 +39,7 @@ define i32 @lshr_C1_add_A_C2_i32(i32 %A) { define <4 x i32> @shl_C1_add_A_C2_v4i32(<4 x i16> %A) { ; CHECK-LABEL: @shl_C1_add_A_C2_v4i32( -; CHECK-NEXT: [[B:%.*]] = zext <4 x i16> %A to <4 x i32> +; CHECK-NEXT: [[B:%.*]] = zext <4 x i16> [[A:%.*]] to <4 x i32> ; CHECK-NEXT: [[D:%.*]] = shl <4 x i32> , [[B]] ; CHECK-NEXT: ret <4 x i32> [[D]] ; @@ -51,7 +51,7 @@ define <4 x i32> @shl_C1_add_A_C2_v4i32(<4 x i16> %A) { define <4 x i32> @ashr_C1_add_A_C2_v4i32(<4 x i32> %A) { ; CHECK-LABEL: @ashr_C1_add_A_C2_v4i32( -; CHECK-NEXT: [[B:%.*]] = and <4 x i32> %A, +; CHECK-NEXT: [[B:%.*]] = and <4 x i32> [[A:%.*]], ; CHECK-NEXT: [[D:%.*]] = ashr <4 x i32> , [[B]] ; CHECK-NEXT: ret <4 x i32> [[D]] ; @@ -63,7 +63,7 @@ define <4 x i32> @ashr_C1_add_A_C2_v4i32(<4 x i32> %A) { define <4 x i32> @lshr_C1_add_A_C2_v4i32(<4 x i32> %A) { ; CHECK-LABEL: @lshr_C1_add_A_C2_v4i32( -; CHECK-NEXT: [[B:%.*]] = and <4 x i32> %A, +; CHECK-NEXT: [[B:%.*]] = and <4 x i32> [[A:%.*]], ; CHECK-NEXT: [[D:%.*]] = lshr <4 x i32> , [[B]] ; CHECK-NEXT: ret <4 x i32> [[D]] ; @@ -72,3 +72,54 @@ define <4 x i32> @lshr_C1_add_A_C2_v4i32(<4 x i32> %A) { %D = lshr <4 x i32> , %C ret <4 x i32> %D } + +define <4 x i32> @shl_C1_add_A_C2_v4i32_splat(i16 %I) { +; CHECK-LABEL: @shl_C1_add_A_C2_v4i32_splat( +; CHECK-NEXT: [[A:%.*]] = zext i16 [[I:%.*]] to i32 +; CHECK-NEXT: [[B:%.*]] = insertelement <4 x i32> undef, i32 [[A]], i32 0 +; CHECK-NEXT: [[C:%.*]] = shufflevector <4 x i32> [[B]], <4 x i32> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: [[D:%.*]] = add <4 x i32> [[C]], +; CHECK-NEXT: [[E:%.*]] = shl <4 x i32> , [[D]] +; CHECK-NEXT: ret <4 x i32> [[E]] +; + %A = zext i16 %I to i32 + %B = insertelement <4 x i32> undef, i32 %A, i32 0 + %C = shufflevector <4 x i32> %B, <4 x i32> undef, <4 x i32> zeroinitializer + %D = add <4 x i32> %C, + %E = shl <4 x i32> , %D + ret <4 x i32> %E +} + +define <4 x i32> @ashr_C1_add_A_C2_v4i32_splat(i16 %I) { +; CHECK-LABEL: @ashr_C1_add_A_C2_v4i32_splat( +; CHECK-NEXT: [[A:%.*]] = zext i16 [[I:%.*]] to i32 +; CHECK-NEXT: [[B:%.*]] = insertelement <4 x i32> undef, i32 [[A]], i32 0 +; CHECK-NEXT: [[C:%.*]] = shufflevector <4 x i32> [[B]], <4 x i32> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: [[D:%.*]] = add <4 x i32> [[C]], +; CHECK-NEXT: [[E:%.*]] = ashr <4 x i32> , [[D]] +; CHECK-NEXT: ret <4 x i32> [[E]] +; + %A = zext i16 %I to i32 + %B = insertelement <4 x i32> undef, i32 %A, i32 0 + %C = shufflevector <4 x i32> %B, <4 x i32> undef, <4 x i32> zeroinitializer + %D = add <4 x i32> %C, + %E = ashr <4 x i32> , %D + ret <4 x i32> %E +} + +define <4 x i32> @lshr_C1_add_A_C2_v4i32_splat(i16 %I) { +; CHECK-LABEL: @lshr_C1_add_A_C2_v4i32_splat( +; CHECK-NEXT: [[A:%.*]] = zext i16 [[I:%.*]] to i32 +; CHECK-NEXT: [[B:%.*]] = insertelement <4 x i32> undef, i32 [[A]], i32 0 +; CHECK-NEXT: [[C:%.*]] = shufflevector <4 x i32> [[B]], <4 x i32> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: [[D:%.*]] = add <4 x i32> [[C]], +; CHECK-NEXT: [[E:%.*]] = lshr <4 x i32> , [[D]] +; CHECK-NEXT: ret <4 x i32> [[E]] +; + %A = zext i16 %I to i32 + %B = insertelement <4 x i32> undef, i32 %A, i32 0 + %C = shufflevector <4 x i32> %B, <4 x i32> undef, <4 x i32> zeroinitializer + %D = add <4 x i32> %C, + %E = lshr <4 x i32> , %D + ret <4 x i32> %E +}