From 5ec1d7135720fa1ac06b6af35a39009891b72a7e Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sun, 15 Jan 2017 23:45:03 +0000 Subject: [PATCH] [InstCombine] add tests to show missed vector folds; NFC Also, add comments and remove bogus comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292082 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/apint-shift.ll | 54 +++++++++++++++++----- test/Transforms/InstCombine/shift.ll | 3 +- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/test/Transforms/InstCombine/apint-shift.ll b/test/Transforms/InstCombine/apint-shift.ll index e1e6b7c48c4..d3dfc7f8f81 100644 --- a/test/Transforms/InstCombine/apint-shift.ll +++ b/test/Transforms/InstCombine/apint-shift.ll @@ -101,14 +101,29 @@ define i17 @test9(i17 %A) { ret i17 %C } -define i19 @test10(i19 %A) { +; shl (lshr X, C), C --> and X, C' + +define i19 @test10(i19 %X) { ; CHECK-LABEL: @test10( -; CHECK-NEXT: [[B:%.*]] = and i19 %A, -262144 -; CHECK-NEXT: ret i19 [[B]] +; CHECK-NEXT: [[SH1:%.*]] = and i19 %X, -262144 +; CHECK-NEXT: ret i19 [[SH1]] +; + %sh1 = lshr i19 %X, 18 + %sh2 = shl i19 %sh1, 18 + ret i19 %sh2 +} + +; FIXME: Same as above with vectors. + +define <2 x i19> @test10_splat_vec(<2 x i19> %X) { +; CHECK-LABEL: @test10_splat_vec( +; CHECK-NEXT: [[SH1:%.*]] = lshr <2 x i19> %X, +; CHECK-NEXT: [[SH2:%.*]] = shl nuw <2 x i19> [[SH1]], +; CHECK-NEXT: ret <2 x i19> [[SH2]] ; - %B = lshr i19 %A, 18 - %C = shl i19 %B, 18 - ret i19 %C + %sh1 = lshr <2 x i19> %X, + %sh2 = shl <2 x i19> %sh1, + ret <2 x i19> %sh2 } ; Don't hide the shl from scalar evolution. DAGCombine will get it. @@ -125,14 +140,29 @@ define i23 @test11(i23 %A) { ret i23 %C } -define i47 @test12(i47 %A) { +; shl (ashr X, C), C --> and X, C' + +define i47 @test12(i47 %X) { ; CHECK-LABEL: @test12( -; CHECK-NEXT: [[B1:%.*]] = and i47 %A, -256 -; CHECK-NEXT: ret i47 [[B1]] +; CHECK-NEXT: [[SH11:%.*]] = and i47 %X, -256 +; CHECK-NEXT: ret i47 [[SH11]] +; + %sh1 = ashr i47 %X, 8 + %sh2 = shl i47 %sh1, 8 + ret i47 %sh2 +} + +; FIXME: Same as above with vectors. + +define <2 x i47> @test12_splat_vec(<2 x i47> %X) { +; CHECK-LABEL: @test12_splat_vec( +; CHECK-NEXT: [[SH1:%.*]] = ashr <2 x i47> %X, +; CHECK-NEXT: [[SH2:%.*]] = shl nsw <2 x i47> [[SH1]], +; CHECK-NEXT: ret <2 x i47> [[SH2]] ; - %B = ashr i47 %A, 8 - %C = shl i47 %B, 8 - ret i47 %C + %sh1 = ashr <2 x i47> %X, + %sh2 = shl <2 x i47> %sh1, + ret <2 x i47> %sh2 } ; Don't hide the shl from scalar evolution. DAGCombine will get it. diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll index 98356cbe2aa..55517e350a1 100644 --- a/test/Transforms/InstCombine/shift.ll +++ b/test/Transforms/InstCombine/shift.ll @@ -161,9 +161,8 @@ define i8 @test9(i8 %A) { ret i8 %C } -;; This transformation is deferred to DAGCombine: ;; (A >> 7) << 7 === A & 128 -;; The shl may be valuable to scalar evolution. + define i8 @test10(i8 %A) { ; CHECK-LABEL: @test10( ; CHECK-NEXT: [[B:%.*]] = and i8 %A, -128 -- 2.50.1