1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -passes=jump-threading,correlated-propagation < %s | FileCheck %s
4 ; This runs both jump threading and CVP to query values in the right order.
5 ; The comparison should not fold.
7 define void @test(i32 %n, i1 %c, i1 %c2) {
8 ; CHECK-LABEL: define void @test(
9 ; CHECK-SAME: i32 [[N:%.*]], i1 [[C:%.*]], i1 [[C2:%.*]]) {
11 ; CHECK-NEXT: br label [[LOOP:%.*]]
13 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ], [ 0, [[ENTRY:%.*]] ]
14 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[IV]], 0
15 ; CHECK-NEXT: call void @use(i1 [[CMP]])
16 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
17 ; CHECK-NEXT: br label [[LOOP2:%.*]]
19 ; CHECK-NEXT: br i1 [[C]], label [[LOOP2_LATCH:%.*]], label [[LOOP2_LATCH]]
21 ; CHECK-NEXT: br i1 [[C2]], label [[LOOP_LATCH]], label [[LOOP2]]
23 ; CHECK-NEXT: [[EXIT_COND:%.*]] = icmp eq i32 [[IV_NEXT]], [[N]]
24 ; CHECK-NEXT: br i1 [[EXIT_COND]], label [[EXIT:%.*]], label [[LOOP]]
26 ; CHECK-NEXT: ret void
32 %iv = phi i32 [ %iv.next, %loop.latch ], [ 0, %entry ]
33 %cmp = icmp eq i32 %iv, 0
34 call void @use(i1 %cmp)
35 %iv.next = add nuw nsw i32 %iv, 1
39 br i1 %c, label %loop2.latch, label %loop2.split
45 br i1 %c2, label %loop.latch, label %loop2
48 %exit.cond = icmp eq i32 %iv.next, %n
49 br i1 %exit.cond, label %exit, label %loop