forked from OSchip/llvm-project
[InstCombine] Add some basic trunc(lshr(zext(x),c)) tests
Copied from the sext equivalents
This commit is contained in:
parent
cc3b8e730e
commit
7a55989dc4
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue