Skip to content

Commit c2d68c4

Browse files
committed
[InstCombine] Add tests for propagating flags when folding consecutative shifts; NFC
1 parent febfbff commit c2d68c4

File tree

1 file changed

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

1 file changed

+80
-0
lines changed

llvm/test/Transforms/InstCombine/shift.ll

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,4 +2240,84 @@ define i129 @shift_zext_not_nneg(i8 %arg) {
22402240
ret i129 %shl
22412241
}
22422242

2243+
define i8 @src_shl_nsw(i8 %x) {
2244+
; CHECK-LABEL: @src_shl_nsw(
2245+
; CHECK-NEXT: [[R:%.*]] = shl i8 32, [[X:%.*]]
2246+
; CHECK-NEXT: ret i8 [[R]]
2247+
;
2248+
%sh = shl nsw i8 1, %x
2249+
%r = shl nsw i8 %sh, 5
2250+
ret i8 %r
2251+
}
2252+
2253+
define i8 @src_shl_nsw_fail(i8 %x) {
2254+
; CHECK-LABEL: @src_shl_nsw_fail(
2255+
; CHECK-NEXT: [[R:%.*]] = shl i8 32, [[X:%.*]]
2256+
; CHECK-NEXT: ret i8 [[R]]
2257+
;
2258+
%sh = shl nsw i8 1, %x
2259+
%r = shl i8 %sh, 5
2260+
ret i8 %r
2261+
}
2262+
2263+
define i8 @src_shl_nuw(i8 %x) {
2264+
; CHECK-LABEL: @src_shl_nuw(
2265+
; CHECK-NEXT: [[R:%.*]] = shl i8 12, [[X:%.*]]
2266+
; CHECK-NEXT: ret i8 [[R]]
2267+
;
2268+
%sh = shl nuw i8 3, %x
2269+
%r = shl nuw i8 %sh, 2
2270+
ret i8 %r
2271+
}
2272+
2273+
define i8 @src_shl_nuw_fail(i8 %x) {
2274+
; CHECK-LABEL: @src_shl_nuw_fail(
2275+
; CHECK-NEXT: [[R:%.*]] = shl i8 12, [[X:%.*]]
2276+
; CHECK-NEXT: ret i8 [[R]]
2277+
;
2278+
%sh = shl i8 3, %x
2279+
%r = shl nuw i8 %sh, 2
2280+
ret i8 %r
2281+
}
2282+
2283+
define i8 @src_lshr_exact(i8 %x) {
2284+
; CHECK-LABEL: @src_lshr_exact(
2285+
; CHECK-NEXT: [[R:%.*]] = lshr i8 48, [[X:%.*]]
2286+
; CHECK-NEXT: ret i8 [[R]]
2287+
;
2288+
%sh = lshr exact i8 96, %x
2289+
%r = lshr exact i8 %sh, 1
2290+
ret i8 %r
2291+
}
2292+
2293+
define i8 @src_lshr_exact_fail(i8 %x) {
2294+
; CHECK-LABEL: @src_lshr_exact_fail(
2295+
; CHECK-NEXT: [[R:%.*]] = lshr i8 48, [[X:%.*]]
2296+
; CHECK-NEXT: ret i8 [[R]]
2297+
;
2298+
%sh = lshr exact i8 96, %x
2299+
%r = lshr i8 %sh, 1
2300+
ret i8 %r
2301+
}
2302+
2303+
define i8 @src_ashr_exact(i8 %x) {
2304+
; CHECK-LABEL: @src_ashr_exact(
2305+
; CHECK-NEXT: [[R:%.*]] = ashr i8 -8, [[X:%.*]]
2306+
; CHECK-NEXT: ret i8 [[R]]
2307+
;
2308+
%sh = ashr exact i8 -32, %x
2309+
%r = ashr exact i8 %sh, 2
2310+
ret i8 %r
2311+
}
2312+
2313+
define i8 @src_ashr_exact_fail(i8 %x) {
2314+
; CHECK-LABEL: @src_ashr_exact_fail(
2315+
; CHECK-NEXT: [[R:%.*]] = ashr i8 -8, [[X:%.*]]
2316+
; CHECK-NEXT: ret i8 [[R]]
2317+
;
2318+
%sh = ashr i8 -32, %x
2319+
%r = ashr exact i8 %sh, 2
2320+
ret i8 %r
2321+
}
2322+
22432323
declare i16 @llvm.umax.i16(i16, i16)

0 commit comments

Comments
 (0)