Skip to content

Commit bc37712

Browse files
committed
Precommit tests
Change-Id: I8ec210209522573a97773201e08dfea8d6b9d78d
1 parent 9981afc commit bc37712

File tree

1 file changed

+99
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+99
-0
lines changed

llvm/test/Transforms/InstCombine/cast.ll

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
; RUN: opt < %s -passes=instcombine -S -data-layout="E-p:64:64:64-p1:32:32:32-p2:64:64:64-p3:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n8:16:32:64" -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat | FileCheck %s --check-prefixes=ALL,BE
66
; RUN: opt < %s -passes=instcombine -S -data-layout="e-p:64:64:64-p1:32:32:32-p2:64:64:64-p3:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n8:16:32:64" -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat | FileCheck %s --check-prefixes=ALL,LE
77

8+
declare void @use_i8(i8)
89
declare void @use_i32(i32)
910
declare void @use_v2i32(<2 x i32>)
1011

@@ -2041,6 +2042,104 @@ define <2 x i8> @trunc_lshr_zext_uses1(<2 x i8> %A) {
20412042
ret <2 x i8> %D
20422043
}
20432044

2045+
define i8 @trunc_lshr_ext_halfWidth(i16 %a, i16 %b, i16 range(i16 0, 8) %shiftAmt) {
2046+
; ALL-LABEL: @trunc_lshr_ext_halfWidth(
2047+
; ALL-NEXT: [[ZEXT_A:%.*]] = zext i16 [[A:%.*]] to i32
2048+
; ALL-NEXT: [[ZEXT_B:%.*]] = zext i16 [[B:%.*]] to i32
2049+
; ALL-NEXT: [[ZEXT_SHIFTAMT:%.*]] = zext nneg i16 [[SHIFTAMT:%.*]] to i32
2050+
; ALL-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[ZEXT_A]], [[ZEXT_B]]
2051+
; ALL-NEXT: [[SHR:%.*]] = lshr i32 [[ADD]], [[ZEXT_SHIFTAMT]]
2052+
; ALL-NEXT: [[TRUNC:%.*]] = trunc i32 [[SHR]] to i8
2053+
; ALL-NEXT: ret i8 [[TRUNC]]
2054+
;
2055+
%zext_a = zext i16 %a to i32
2056+
%zext_b = zext i16 %b to i32
2057+
%zext_shiftAmt = zext i16 %shiftAmt to i32
2058+
%add = add nuw nsw i32 %zext_a, %zext_b
2059+
%shr = lshr i32 %add, %zext_shiftAmt
2060+
%trunc = trunc i32 %shr to i8
2061+
ret i8 %trunc
2062+
}
2063+
2064+
define i8 @trunc_lshr_ext_halfWidth_rhsRange_neg(i16 %a, i16 %b, i16 %shiftAmt) {
2065+
; ALL-LABEL: @trunc_lshr_ext_halfWidth_rhsRange_neg(
2066+
; ALL-NEXT: [[ZEXT_A:%.*]] = zext i16 [[A:%.*]] to i32
2067+
; ALL-NEXT: [[ZEXT_B:%.*]] = zext i16 [[B:%.*]] to i32
2068+
; ALL-NEXT: [[ZEXT_SHIFTAMT:%.*]] = zext nneg i16 [[SHIFTAMT:%.*]] to i32
2069+
; ALL-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[ZEXT_A]], [[ZEXT_B]]
2070+
; ALL-NEXT: [[SHR:%.*]] = lshr i32 [[ADD]], [[ZEXT_SHIFTAMT]]
2071+
; ALL-NEXT: [[TRUNC:%.*]] = trunc i32 [[SHR]] to i8
2072+
; ALL-NEXT: ret i8 [[TRUNC]]
2073+
;
2074+
%zext_a = zext i16 %a to i32
2075+
%zext_b = zext i16 %b to i32
2076+
%zext_shiftAmt = zext i16 %shiftAmt to i32
2077+
%add = add nuw nsw i32 %zext_a, %zext_b
2078+
%shr = lshr i32 %add, %zext_shiftAmt
2079+
%trunc = trunc i32 %shr to i8
2080+
ret i8 %trunc
2081+
}
2082+
2083+
define i8 @trunc_lshr_ext_halfWidth_twouse_neg1(i16 %a, i16 %b, i16 range(i16 0, 8) %shiftAmt) {
2084+
; ALL-LABEL: @trunc_lshr_ext_halfWidth_twouse_neg1(
2085+
; ALL-NEXT: [[ZEXT_A:%.*]] = zext i16 [[A:%.*]] to i32
2086+
; ALL-NEXT: [[ZEXT_B:%.*]] = zext i16 [[B:%.*]] to i32
2087+
; ALL-NEXT: [[ZEXT_SHIFTAMT:%.*]] = zext nneg i16 [[SHIFTAMT:%.*]] to i32
2088+
; ALL-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[ZEXT_A]], [[ZEXT_B]]
2089+
; ALL-NEXT: call void @use_i32(i32 [[ADD]])
2090+
; ALL-NEXT: [[SHR:%.*]] = lshr i32 [[ADD]], [[ZEXT_SHIFTAMT]]
2091+
; ALL-NEXT: [[TRUNC:%.*]] = trunc i32 [[SHR]] to i8
2092+
; ALL-NEXT: ret i8 [[TRUNC]]
2093+
;
2094+
%zext_a = zext i16 %a to i32
2095+
%zext_b = zext i16 %b to i32
2096+
%zext_shiftAmt = zext i16 %shiftAmt to i32
2097+
%add = add nuw nsw i32 %zext_a, %zext_b
2098+
call void @use_i32(i32 %add)
2099+
%shr = lshr i32 %add, %zext_shiftAmt
2100+
%trunc = trunc i32 %shr to i8
2101+
ret i8 %trunc
2102+
}
2103+
2104+
define i8 @trunc_lshr_ext_halfWidth_twouse_neg2(i16 %a, i16 %b, i16 range(i16 0, 8) %shiftAmt) {
2105+
; ALL-LABEL: @trunc_lshr_ext_halfWidth_twouse_neg2(
2106+
; ALL-NEXT: [[ZEXT_A:%.*]] = zext i16 [[A:%.*]] to i32
2107+
; ALL-NEXT: [[ZEXT_B:%.*]] = zext i16 [[B:%.*]] to i32
2108+
; ALL-NEXT: [[ZEXT_SHIFTAMT:%.*]] = zext nneg i16 [[SHIFTAMT:%.*]] to i32
2109+
; ALL-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[ZEXT_A]], [[ZEXT_B]]
2110+
; ALL-NEXT: [[SHR:%.*]] = lshr i32 [[ADD]], [[ZEXT_SHIFTAMT]]
2111+
; ALL-NEXT: call void @use_i32(i32 [[SHR]])
2112+
; ALL-NEXT: [[TRUNC:%.*]] = trunc i32 [[SHR]] to i8
2113+
; ALL-NEXT: ret i8 [[TRUNC]]
2114+
;
2115+
%zext_a = zext i16 %a to i32
2116+
%zext_b = zext i16 %b to i32
2117+
%zext_shiftAmt = zext i16 %shiftAmt to i32
2118+
%add = add nuw nsw i32 %zext_a, %zext_b
2119+
%shr = lshr i32 %add, %zext_shiftAmt
2120+
call void @use_i32(i32 %shr)
2121+
%trunc = trunc i32 %shr to i8
2122+
ret i8 %trunc
2123+
}
2124+
2125+
; The narrowing transform only happens for integer types.
2126+
define <2 x i8> @trunc_lshr_ext_halfWidth_vector_neg(<2 x i16> %a, <2 x i16> %b) {
2127+
; ALL-LABEL: @trunc_lshr_ext_halfWidth_vector_neg(
2128+
; ALL-NEXT: [[ZEXT_A:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
2129+
; ALL-NEXT: [[ZEXT_B:%.*]] = zext <2 x i16> [[B:%.*]] to <2 x i32>
2130+
; ALL-NEXT: [[ADD:%.*]] = add nuw nsw <2 x i32> [[ZEXT_A]], [[ZEXT_B]]
2131+
; ALL-NEXT: [[SHR:%.*]] = lshr <2 x i32> [[ADD]], splat (i32 6)
2132+
; ALL-NEXT: [[TRUNC:%.*]] = trunc <2 x i32> [[SHR]] to <2 x i8>
2133+
; ALL-NEXT: ret <2 x i8> [[TRUNC]]
2134+
;
2135+
%zext_a = zext <2 x i16> %a to <2 x i32>
2136+
%zext_b = zext <2 x i16> %b to <2 x i32>
2137+
%add = add nuw nsw <2 x i32> %zext_a, %zext_b
2138+
%shr = lshr <2 x i32> %add, <i32 6, i32 6>
2139+
%trunc = trunc <2 x i32> %shr to <2 x i8>
2140+
ret <2 x i8> %trunc
2141+
}
2142+
20442143
; The following four tests sext + lshr + trunc patterns.
20452144
; PR33078
20462145

0 commit comments

Comments
 (0)