File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
llvm/test/Transforms/InstCombine Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff 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+
323340declare i32 @llvm.ctlz.i32 (i32 , i1 immarg)
324341declare i64 @llvm.ctlz.i64 (i64 , i1 immarg)
325342declare <4 x i32 > @llvm.ctlz.v4i32 (<4 x i32 >, i1 )
You can’t perform that action at this time.
0 commit comments