Skip to content

Commit 7c48f4c

Browse files
committed
[InstCombine] Add pre-commit tests. NFC.
1 parent 7c010bf commit 7c48f4c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

llvm/test/Transforms/InstCombine/bit_ceil.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,23 @@ define i32 @pr91691_keep_nsw(i32 %0) {
320320
ret i32 %7
321321
}
322322

323+
define i32 @test_drop_range_attr(i32 %x) {
324+
; CHECK-LABEL: @test_drop_range_attr(
325+
; CHECK-NEXT: [[CTLZ:%.*]] = call range(i32 1, 33) i32 @llvm.ctlz.i32(i32 [[X:%.*]], i1 false)
326+
; CHECK-NEXT: [[TMP1:%.*]] = sub nsw i32 0, [[CTLZ]]
327+
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 31
328+
; CHECK-NEXT: [[SEL:%.*]] = shl nuw i32 1, [[TMP2]]
329+
; CHECK-NEXT: ret i32 [[SEL]]
330+
;
331+
%ctlz = call range(i32 1, 33) i32 @llvm.ctlz.i32(i32 %x, i1 false)
332+
%sub = sub i32 32, %ctlz
333+
%shl = shl i32 1, %sub
334+
%dec = add i32 %x, -1
335+
%ult = icmp ult i32 %dec, -2
336+
%sel = select i1 %ult, i32 %shl, i32 1
337+
ret i32 %sel
338+
}
339+
323340
declare i32 @llvm.ctlz.i32(i32, i1 immarg)
324341
declare i64 @llvm.ctlz.i64(i64, i1 immarg)
325342
declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1)

0 commit comments

Comments
 (0)