1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=correlated-propagation -S %s | FileCheck %s
4 ; Check that shift is not removed by CVP because of incorrect range returned by LVI::getConstantRangeAtUse.
5 ; https://github.com/llvm/llvm-project/issues/60629
7 define i32 @test(i32 %arg) {
10 ; CHECK-NEXT: br label [[LOOP:%.*]]
12 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 127, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[DO_SHIFT:%.*]] ]
13 ; CHECK-NEXT: [[SHIFTED_IV:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[SHIFT:%.*]], [[DO_SHIFT]] ]
14 ; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
15 ; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp sgt i32 [[IV]], 127
16 ; CHECK-NEXT: br i1 [[LOOP_COND]], label [[EXIT:%.*]], label [[DO_SHIFT]]
18 ; CHECK-NEXT: [[SHIFT]] = ashr i32 [[IV]], [[ARG:%.*]]
19 ; CHECK-NEXT: br label [[LOOP]]
21 ; CHECK-NEXT: br label [[EXIT]]
23 ; CHECK-NEXT: [[RETVAL:%.*]] = phi i32 [ 0, [[BB1:%.*]] ], [ [[SHIFTED_IV]], [[LOOP]] ]
24 ; CHECK-NEXT: ret i32 [[RETVAL]]
29 loop: ; preds = %do.shift, %entry
30 %iv = phi i32 [ 127, %entry ], [ %iv.next, %do.shift ]
31 %shifted.iv = phi i32 [ 0, %entry ], [ %shift, %do.shift ]
32 %iv.next = add i32 %iv, 1
33 %loop_cond = icmp sgt i32 %iv, 127
34 br i1 %loop_cond, label %exit, label %do.shift
36 do.shift: ; preds = %loop
37 %shift = ashr i32 %iv, %arg
40 bb1: ; No predecessors!
43 exit: ; preds = %loop, %bb1
44 %retval = phi i32 [ 0, %bb1 ], [ %shifted.iv, %loop ]