diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-01-15 23:45:03 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-01-15 23:45:03 +0000 |
commit | 21347ffddf8ece47df52d09fee3e73f450caf6d6 (patch) | |
tree | 3af9dd2f630f18901abb1240a5b8a82c8e45e208 /llvm/test/Transforms/InstCombine/apint-shift.ll | |
parent | 5060fe9dc0641229da74aecedb16013ef2e462fb (diff) | |
download | bcm5719-llvm-21347ffddf8ece47df52d09fee3e73f450caf6d6.tar.gz bcm5719-llvm-21347ffddf8ece47df52d09fee3e73f450caf6d6.zip |
[InstCombine] add tests to show missed vector folds; NFC
Also, add comments and remove bogus comment.
llvm-svn: 292082
Diffstat (limited to 'llvm/test/Transforms/InstCombine/apint-shift.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/apint-shift.ll | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/llvm/test/Transforms/InstCombine/apint-shift.ll b/llvm/test/Transforms/InstCombine/apint-shift.ll index e1e6b7c48c4..d3dfc7f8f81 100644 --- a/llvm/test/Transforms/InstCombine/apint-shift.ll +++ b/llvm/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, <i19 18, i19 18> +; CHECK-NEXT: [[SH2:%.*]] = shl nuw <2 x i19> [[SH1]], <i19 18, i19 18> +; 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, <i19 18, i19 18> + %sh2 = shl <2 x i19> %sh1, <i19 18, i19 18> + 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, <i47 8, i47 8> +; CHECK-NEXT: [[SH2:%.*]] = shl nsw <2 x i47> [[SH1]], <i47 8, i47 8> +; 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, <i47 8, i47 8> + %sh2 = shl <2 x i47> %sh1, <i47 8, i47 8> + ret <2 x i47> %sh2 } ; Don't hide the shl from scalar evolution. DAGCombine will get it. |