summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-02-01 21:31:34 +0000
committerSanjay Patel <spatel@rotateright.com>2017-02-01 21:31:34 +0000
commitc56d1ccd797e96869f7d7ee4a78126b136f709fc (patch)
treef4fd9c35b5c942ab615ce6e5a6ff6481e1e5284d /llvm/test/Transforms
parent3c6b3ba258ee547b8e7b6acaba7b8d60ef7d8143 (diff)
downloadbcm5719-llvm-c56d1ccd797e96869f7d7ee4a78126b136f709fc.tar.gz
bcm5719-llvm-c56d1ccd797e96869f7d7ee4a78126b136f709fc.zip
[InstCombine] move folds for shift-shift pairs; NFCI
Although this is 'no-functional-change-intended', I'm adding tests for shl-shl and lshr-lshr pairs because there is no existing test coverage for those folds. It seems like we should be able to remove some code from foldShiftedShift() at this point because we're handling those patterns on the general path. llvm-svn: 293814
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstCombine/apint-shift.ll52
1 files changed, 52 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/apint-shift.ll b/llvm/test/Transforms/InstCombine/apint-shift.ll
index fc1934b576f..f1276beec9f 100644
--- a/llvm/test/Transforms/InstCombine/apint-shift.ll
+++ b/llvm/test/Transforms/InstCombine/apint-shift.ll
@@ -126,6 +126,32 @@ define <2 x i19> @lshr_lshr_splat_vec(<2 x i19> %X) {
ret <2 x i19> %sh2
}
+define i9 @multituse_lshr_lshr(i9 %x) {
+; CHECK-LABEL: @multituse_lshr_lshr(
+; CHECK-NEXT: [[SH1:%.*]] = lshr i9 %x, 2
+; CHECK-NEXT: [[SH2:%.*]] = lshr i9 %x, 5
+; CHECK-NEXT: [[MUL:%.*]] = mul i9 [[SH1]], [[SH2]]
+; CHECK-NEXT: ret i9 [[MUL]]
+;
+ %sh1 = lshr i9 %x, 2
+ %sh2 = lshr i9 %sh1, 3
+ %mul = mul i9 %sh1, %sh2
+ ret i9 %mul
+}
+
+define <2 x i9> @multiuse_lshr_lshr_splat(<2 x i9> %x) {
+; CHECK-LABEL: @multiuse_lshr_lshr_splat(
+; CHECK-NEXT: [[SH1:%.*]] = lshr <2 x i9> %x, <i9 2, i9 2>
+; CHECK-NEXT: [[SH2:%.*]] = lshr <2 x i9> %x, <i9 5, i9 5>
+; CHECK-NEXT: [[MUL:%.*]] = mul <2 x i9> [[SH1]], [[SH2]]
+; CHECK-NEXT: ret <2 x i9> [[MUL]]
+;
+ %sh1 = lshr <2 x i9> %x, <i9 2, i9 2>
+ %sh2 = lshr <2 x i9> %sh1, <i9 3, i9 3>
+ %mul = mul <2 x i9> %sh1, %sh2
+ ret <2 x i9> %mul
+}
+
; Two left shifts in the same direction:
; shl (shl X, C1), C2 --> shl X, C1 + C2
@@ -139,6 +165,32 @@ define <2 x i19> @shl_shl_splat_vec(<2 x i19> %X) {
ret <2 x i19> %sh2
}
+define i42 @multiuse_shl_shl(i42 %x) {
+; CHECK-LABEL: @multiuse_shl_shl(
+; CHECK-NEXT: [[SH1:%.*]] = shl i42 %x, 8
+; CHECK-NEXT: [[SH2:%.*]] = shl i42 %x, 17
+; CHECK-NEXT: [[MUL:%.*]] = mul i42 [[SH1]], [[SH2]]
+; CHECK-NEXT: ret i42 [[MUL]]
+;
+ %sh1 = shl i42 %x, 8
+ %sh2 = shl i42 %sh1, 9
+ %mul = mul i42 %sh1, %sh2
+ ret i42 %mul
+}
+
+define <2 x i42> @mulituse_shl_shl_splat(<2 x i42> %x) {
+; CHECK-LABEL: @mulituse_shl_shl_splat(
+; CHECK-NEXT: [[SH1:%.*]] = shl <2 x i42> %x, <i42 8, i42 8>
+; CHECK-NEXT: [[SH2:%.*]] = shl <2 x i42> %x, <i42 17, i42 17>
+; CHECK-NEXT: [[MUL:%.*]] = mul <2 x i42> [[SH1]], [[SH2]]
+; CHECK-NEXT: ret <2 x i42> [[MUL]]
+;
+ %sh1 = shl <2 x i42> %x, <i42 8, i42 8>
+ %sh2 = shl <2 x i42> %sh1, <i42 9, i42 9>
+ %mul = mul <2 x i42> %sh1, %sh2
+ ret <2 x i42> %mul
+}
+
; Equal shift amounts in opposite directions become bitwise 'and':
; lshr (shl X, C), C --> and X, C'
OpenPOWER on IntegriCloud