[llvm] r292082 - [InstCombine] add tests to show missed vector folds; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 15 15:45:03 PST 2017
Author: spatel
Date: Sun Jan 15 17:45:03 2017
New Revision: 292082
URL: http://llvm.org/viewvc/llvm-project?rev=292082&view=rev
Log:
[InstCombine] add tests to show missed vector folds; NFC
Also, add comments and remove bogus comment.
Modified:
llvm/trunk/test/Transforms/InstCombine/apint-shift.ll
llvm/trunk/test/Transforms/InstCombine/shift.ll
Modified: llvm/trunk/test/Transforms/InstCombine/apint-shift.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/apint-shift.ll?rev=292082&r1=292081&r2=292082&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/apint-shift.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/apint-shift.ll Sun Jan 15 17:45:03 2017
@@ -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.
Modified: llvm/trunk/test/Transforms/InstCombine/shift.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/shift.ll?rev=292082&r1=292081&r2=292082&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/shift.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/shift.ll Sun Jan 15 17:45:03 2017
@@ -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
More information about the llvm-commits
mailing list