From: Sanjay Patel Date: Thu, 20 Apr 2017 22:18:47 +0000 (+0000) Subject: [InstCombine] add tests for shl+shr demanded bits splat vector folds; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c086bdaf50f57697c022a09b97cce4e7150c7744;p=llvm [InstCombine] add tests for shl+shr demanded bits splat vector folds; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300907 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll index abcb8f17525..6a6c1880c5e 100644 --- a/test/Transforms/InstCombine/shift.ll +++ b/test/Transforms/InstCombine/shift.ll @@ -1073,6 +1073,18 @@ define i32 @test54(i32 %x) { ret i32 %and } +define <2 x i32> @test54_splat_vec(<2 x i32> %x) { +; CHECK-LABEL: @test54_splat_vec( +; CHECK-NEXT: [[SHR2:%.*]] = lshr <2 x i32> %x, +; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> [[SHR2]], +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SHL]], +; CHECK-NEXT: ret <2 x i32> [[AND]] +; + %shr2 = lshr <2 x i32> %x, + %shl = shl <2 x i32> %shr2, + %and = and <2 x i32> %shl, + ret <2 x i32> %and +} define i32 @test55(i32 %x) { ; CHECK-LABEL: @test55( @@ -1099,7 +1111,6 @@ define i32 @test56(i32 %x) { ret i32 %or } - define i32 @test57(i32 %x) { ; CHECK-LABEL: @test57( ; CHECK-NEXT: [[SHR1:%.*]] = lshr i32 %x, 1 @@ -1113,7 +1124,6 @@ define i32 @test57(i32 %x) { ret i32 %or } - define i32 @test58(i32 %x) { ; CHECK-LABEL: @test58( ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 %x, 3 @@ -1126,6 +1136,18 @@ define i32 @test58(i32 %x) { ret i32 %or } +define <2 x i32> @test58_splat_vec(<2 x i32> %x) { +; CHECK-LABEL: @test58_splat_vec( +; CHECK-NEXT: [[SHR:%.*]] = ashr <2 x i32> %x, +; CHECK-NEXT: [[SHL:%.*]] = shl nsw <2 x i32> [[SHR]], +; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[SHL]], +; CHECK-NEXT: ret <2 x i32> [[OR]] +; + %shr = ashr <2 x i32> %x, + %shl = shl <2 x i32> %shr, + %or = or <2 x i32> %shl, + ret <2 x i32> %or +} define i32 @test59(i32 %x) { ; CHECK-LABEL: @test59(