From c8ac2767b624b44cbc5c38de39e8198c5b5771d5 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 30 Jan 2017 15:54:50 +0000 Subject: [PATCH] [InstCombine] add tests for shift-shift patterns; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293487 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/shift.ll | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll index ac5b27648ee..26cb5ddef9b 100644 --- a/test/Transforms/InstCombine/shift.ll +++ b/test/Transforms/InstCombine/shift.ll @@ -882,6 +882,8 @@ define <2 x i32> @test49_splat_vec(<2 x i32> %x) { ret <2 x i32> %B } +; (X <>s C2 --> X >>s (C2-C1) + define i32 @test50(i32 %x) { ; CHECK-LABEL: @test50( ; CHECK-NEXT: [[B:%.*]] = ashr i32 %x, 2 @@ -892,6 +894,21 @@ define i32 @test50(i32 %x) { ret i32 %B } +; (X <>s C2 --> X >>s (C2-C1) + +define <2 x i32> @test50_splat_vec(<2 x i32> %x) { +; CHECK-LABEL: @test50_splat_vec( +; CHECK-NEXT: [[A:%.*]] = shl nsw <2 x i32> %x, +; CHECK-NEXT: [[B:%.*]] = ashr <2 x i32> [[A]], +; CHECK-NEXT: ret <2 x i32> [[B]] +; + %A = shl nsw <2 x i32> %x, + %B = ashr <2 x i32> %A, + ret <2 x i32> %B +} + +; (X <>u C2 --> X >>u (C2-C1) + define i32 @test51(i32 %x) { ; CHECK-LABEL: @test51( ; CHECK-NEXT: [[B:%.*]] = lshr i32 %x, 2 @@ -902,6 +919,46 @@ define i32 @test51(i32 %x) { ret i32 %B } +; (X <>u C2 --> X >>u (C2-C1) with splats +; Also, check that exact is propagated. + +define <2 x i32> @test51_splat_vec(<2 x i32> %x) { +; CHECK-LABEL: @test51_splat_vec( +; CHECK-NEXT: [[A:%.*]] = shl nuw <2 x i32> %x, +; CHECK-NEXT: [[B:%.*]] = lshr exact <2 x i32> [[A]], +; CHECK-NEXT: ret <2 x i32> [[B]] +; + %A = shl nuw <2 x i32> %x, + %B = lshr exact <2 x i32> %A, + ret <2 x i32> %B +} + +; (X << C1) >>u C2 --> X >>u (C2-C1) & (-1 >> C2) + +define i32 @test51_no_nuw(i32 %x) { +; CHECK-LABEL: @test51_no_nuw( +; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 %x, 2 +; CHECK-NEXT: [[B:%.*]] = and i32 [[TMP1]], 536870911 +; CHECK-NEXT: ret i32 [[B]] +; + %A = shl i32 %x, 1 + %B = lshr i32 %A, 3 + ret i32 %B +} + +; (X << C1) >>u C2 --> X >>u (C2-C1) & (-1 >> C2) + +define <2 x i32> @test51_no_nuw_splat_vec(<2 x i32> %x) { +; CHECK-LABEL: @test51_no_nuw_splat_vec( +; CHECK-NEXT: [[A:%.*]] = shl <2 x i32> %x, +; CHECK-NEXT: [[B:%.*]] = lshr <2 x i32> [[A]], +; CHECK-NEXT: ret <2 x i32> [[B]] +; + %A = shl <2 x i32> %x, + %B = lshr <2 x i32> %A, + ret <2 x i32> %B +} + define i32 @test52(i32 %x) { ; CHECK-LABEL: @test52( ; CHECK-NEXT: [[B:%.*]] = shl nsw i32 %x, 2 -- 2.40.0