[llvm] 7a55989 - [InstCombine] Add some basic trunc(lshr(zext(x), c)) tests
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 07:50:09 PDT 2020
Author: Simon Pilgrim
Date: 2020-09-29T15:49:57+01:00
New Revision: 7a55989dc4305e66734bdd84a9f9eefeb9fe64bd
URL: https://github.com/llvm/llvm-project/commit/7a55989dc4305e66734bdd84a9f9eefeb9fe64bd
DIFF: https://github.com/llvm/llvm-project/commit/7a55989dc4305e66734bdd84a9f9eefeb9fe64bd.diff
LOG: [InstCombine] Add some basic trunc(lshr(zext(x),c)) tests
Copied from the sext equivalents
Added:
Modified:
llvm/test/Transforms/InstCombine/cast.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/cast.ll b/llvm/test/Transforms/InstCombine/cast.ll
index 97439606973c..c5f18b4c625e 100644
--- a/llvm/test/Transforms/InstCombine/cast.ll
+++ b/llvm/test/Transforms/InstCombine/cast.ll
@@ -2012,6 +2012,90 @@ define i8 @trunc_lshr_overshift2_sext_uses3(i8 %A) {
ret i8 %D
}
+define i8 @trunc_lshr_zext(i8 %A) {
+; ALL-LABEL: @trunc_lshr_zext(
+; ALL-NEXT: [[TMP1:%.*]] = lshr i8 [[A:%.*]], 6
+; ALL-NEXT: ret i8 [[TMP1]]
+;
+ %B = zext i8 %A to i32
+ %C = lshr i32 %B, 6
+ %D = trunc i32 %C to i8
+ ret i8 %D
+}
+
+define i8 @trunc_lshr_zext_exact(i8 %A) {
+; ALL-LABEL: @trunc_lshr_zext_exact(
+; ALL-NEXT: [[TMP1:%.*]] = lshr i8 [[A:%.*]], 6
+; ALL-NEXT: ret i8 [[TMP1]]
+;
+ %B = zext i8 %A to i32
+ %C = lshr exact i32 %B, 6
+ %D = trunc i32 %C to i8
+ ret i8 %D
+}
+
+define <2 x i8> @trunc_lshr_zext_uniform(<2 x i8> %A) {
+; ALL-LABEL: @trunc_lshr_zext_uniform(
+; ALL-NEXT: [[TMP1:%.*]] = lshr <2 x i8> [[A:%.*]], <i8 6, i8 6>
+; ALL-NEXT: ret <2 x i8> [[TMP1]]
+;
+ %B = zext <2 x i8> %A to <2 x i32>
+ %C = lshr <2 x i32> %B, <i32 6, i32 6>
+ %D = trunc <2 x i32> %C to <2 x i8>
+ ret <2 x i8> %D
+}
+
+define <2 x i8> @trunc_lshr_zext_uniform_undef(<2 x i8> %A) {
+; ALL-LABEL: @trunc_lshr_zext_uniform_undef(
+; ALL-NEXT: [[B:%.*]] = zext <2 x i8> [[A:%.*]] to <2 x i32>
+; ALL-NEXT: [[C:%.*]] = lshr <2 x i32> [[B]], <i32 6, i32 undef>
+; ALL-NEXT: [[D:%.*]] = trunc <2 x i32> [[C]] to <2 x i8>
+; ALL-NEXT: ret <2 x i8> [[D]]
+;
+ %B = zext <2 x i8> %A to <2 x i32>
+ %C = lshr <2 x i32> %B, <i32 6, i32 undef>
+ %D = trunc <2 x i32> %C to <2 x i8>
+ ret <2 x i8> %D
+}
+
+define <2 x i8> @trunc_lshr_zext_nonuniform(<2 x i8> %A) {
+; ALL-LABEL: @trunc_lshr_zext_nonuniform(
+; ALL-NEXT: [[C:%.*]] = lshr <2 x i8> [[A:%.*]], <i8 6, i8 2>
+; ALL-NEXT: ret <2 x i8> [[C]]
+;
+ %B = zext <2 x i8> %A to <2 x i32>
+ %C = lshr <2 x i32> %B, <i32 6, i32 2>
+ %D = trunc <2 x i32> %C to <2 x i8>
+ ret <2 x i8> %D
+}
+
+define <3 x i8> @trunc_lshr_zext_nonuniform_undef(<3 x i8> %A) {
+; ALL-LABEL: @trunc_lshr_zext_nonuniform_undef(
+; ALL-NEXT: [[B:%.*]] = zext <3 x i8> [[A:%.*]] to <3 x i32>
+; ALL-NEXT: [[C:%.*]] = lshr <3 x i32> [[B]], <i32 6, i32 2, i32 undef>
+; ALL-NEXT: [[D:%.*]] = trunc <3 x i32> [[C]] to <3 x i8>
+; ALL-NEXT: ret <3 x i8> [[D]]
+;
+ %B = zext <3 x i8> %A to <3 x i32>
+ %C = lshr <3 x i32> %B, <i32 6, i32 2, i32 undef>
+ %D = trunc <3 x i32> %C to <3 x i8>
+ ret <3 x i8> %D
+}
+
+define <2 x i8> @trunc_lshr_zext_uses1(<2 x i8> %A) {
+; ALL-LABEL: @trunc_lshr_zext_uses1(
+; ALL-NEXT: [[B:%.*]] = zext <2 x i8> [[A:%.*]] to <2 x i32>
+; ALL-NEXT: call void @use_v2i32(<2 x i32> [[B]])
+; ALL-NEXT: [[C:%.*]] = lshr <2 x i8> [[A]], <i8 6, i8 6>
+; ALL-NEXT: ret <2 x i8> [[C]]
+;
+ %B = zext <2 x i8> %A to <2 x i32>
+ call void @use_v2i32(<2 x i32> %B)
+ %C = lshr <2 x i32> %B, <i32 6, i32 6>
+ %D = trunc <2 x i32> %C to <2 x i8>
+ ret <2 x i8> %D
+}
+
; The following four tests sext + lshr + trunc patterns.
; PR33078
More information about the llvm-commits
mailing list