Skip to content

Commit 529b16b

Browse files
Add test case requested in code review
1 parent e26a702 commit 529b16b

File tree

1 file changed

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

1 file changed

+20
-0
lines changed

llvm/test/Transforms/InstCombine/add.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4492,6 +4492,26 @@ define i32 @ceil_div_commuted_multi_use(i32 range(i32 0, 100) %x) {
44924492
ret i32 %r
44934493
}
44944494

4495+
; Multi-use test where only zext has multiple uses - should still optimize
4496+
define i32 @ceil_div_zext_multi_use(i32 range(i32 0, 100) %x) {
4497+
; CHECK-LABEL: @ceil_div_zext_multi_use(
4498+
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 7
4499+
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[AND]], 0
4500+
; CHECK-NEXT: [[EXT:%.*]] = zext i1 [[CMP]] to i32
4501+
; CHECK-NEXT: call void @use_i32(i32 [[EXT]])
4502+
; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i32 [[X]], 7
4503+
; CHECK-NEXT: [[R:%.*]] = lshr i32 [[TMP1]], 3
4504+
; CHECK-NEXT: ret i32 [[R]]
4505+
;
4506+
%shr = lshr i32 %x, 3
4507+
%and = and i32 %x, 7
4508+
%cmp = icmp ne i32 %and, 0
4509+
%ext = zext i1 %cmp to i32
4510+
call void @use_i32(i32 %ext)
4511+
%r = add i32 %shr, %ext
4512+
ret i32 %r
4513+
}
4514+
44954515
; Multi-use with vector type
44964516
define <2 x i32> @ceil_div_vec_multi_use(<2 x i32> range(i32 0, 1000) %x) {
44974517
; CHECK-LABEL: @ceil_div_vec_multi_use(

0 commit comments

Comments
 (0)