Skip to content

Commit e63b7ba

Browse files
authored
[InstCombine][NFC] Add tests for shifts of constants by common factor (#103471)
1 parent 5989709 commit e63b7ba

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

llvm/test/Transforms/InstCombine/shl-factor.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,27 @@ define i6 @sub_shl_same_amount_partial_nuw2(i6 %x, i6 %y, i6 %z) {
265265
ret i6 %diff
266266
}
267267

268+
define i8 @add_shl_same_amount_constants(i8 %z) {
269+
; CHECK-LABEL: @add_shl_same_amount_constants(
270+
; CHECK-NEXT: [[SUM:%.*]] = shl i8 7, [[Z:%.*]]
271+
; CHECK-NEXT: ret i8 [[SUM]]
272+
;
273+
%s1 = shl i8 4, %z
274+
%s2 = shl i8 3, %z
275+
%sum = add i8 %s1, %s2
276+
ret i8 %sum
277+
}
278+
279+
define i8 @add_shl_same_amount_constants_extra_use(i8 %z) {
280+
; CHECK-LABEL: @add_shl_same_amount_constants_extra_use(
281+
; CHECK-NEXT: [[S1:%.*]] = shl i8 4, [[Z:%.*]]
282+
; CHECK-NEXT: [[SUM:%.*]] = shl i8 7, [[Z]]
283+
; CHECK-NEXT: call void @use8(i8 [[S1]])
284+
; CHECK-NEXT: ret i8 [[SUM]]
285+
;
286+
%s1 = shl i8 4, %z
287+
%s2 = shl i8 3, %z
288+
%sum = add i8 %s1, %s2
289+
call void @use8(i8 %s1)
290+
ret i8 %sum
291+
}

0 commit comments

Comments
 (0)