From 1a86607d386c00dbe28f9dc879104c80fad99141 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 30 Jan 2017 18:17:14 +0000 Subject: [InstCombine] add vector splat tests for (X >>?exact C1) << C2 --> X >>?exact (C1-C2); NFC llvm-svn: 293517 --- llvm/test/Transforms/InstCombine/shift.ll | 42 ++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'llvm/test/Transforms') diff --git a/llvm/test/Transforms/InstCombine/shift.ll b/llvm/test/Transforms/InstCombine/shift.ll index 459bd5862bd..0c6655c800d 100644 --- a/llvm/test/Transforms/InstCombine/shift.ll +++ b/llvm/test/Transforms/InstCombine/shift.ll @@ -790,6 +790,8 @@ define i32 @test45(i32 %a) nounwind { ret i32 %z } +; (X >>?exact C1) << C2 --> X >>?exact (C1-C2) + define i32 @test46(i32 %a) { ; CHECK-LABEL: @test46( ; CHECK-NEXT: [[Z:%.*]] = ashr exact i32 %a, 2 @@ -800,14 +802,42 @@ define i32 @test46(i32 %a) { ret i32 %z } -define i32 @test47(i32 %a) { +; (X >>?exact C1) << C2 --> X >>?exact (C1-C2) + +define <2 x i32> @test46_splat_vec(<2 x i32> %a) { +; CHECK-LABEL: @test46_splat_vec( +; CHECK-NEXT: [[Y:%.*]] = ashr exact <2 x i32> %a, +; CHECK-NEXT: [[Z:%.*]] = shl nsw <2 x i32> [[Y]], +; CHECK-NEXT: ret <2 x i32> [[Z]] +; + %y = ashr exact <2 x i32> %a, + %z = shl <2 x i32> %y, + ret <2 x i32> %z +} + +; (X >>?exact C1) << C2 --> X >>?exact (C1-C2) + +define i8 @test47(i8 %a) { ; CHECK-LABEL: @test47( -; CHECK-NEXT: [[Z:%.*]] = lshr exact i32 %a, 2 -; CHECK-NEXT: ret i32 [[Z]] +; CHECK-NEXT: [[Z:%.*]] = lshr exact i8 %a, 2 +; CHECK-NEXT: ret i8 [[Z]] ; - %y = lshr exact i32 %a, 3 - %z = shl i32 %y, 1 - ret i32 %z + %y = lshr exact i8 %a, 3 + %z = shl i8 %y, 1 + ret i8 %z +} + +; (X >>?exact C1) << C2 --> X >>?exact (C1-C2) + +define <2 x i8> @test47_splat_vec(<2 x i8> %a) { +; CHECK-LABEL: @test47_splat_vec( +; CHECK-NEXT: [[Y:%.*]] = lshr exact <2 x i8> %a, +; CHECK-NEXT: [[Z:%.*]] = shl nuw nsw <2 x i8> [[Y]], +; CHECK-NEXT: ret <2 x i8> [[Z]] +; + %y = lshr exact <2 x i8> %a, + %z = shl <2 x i8> %y, + ret <2 x i8> %z } ; (X >>u,exact C1) << C2 --> X << (C2-C1) when C2 > C1 -- cgit v1.2.3