1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -canon-freeze -S | FileCheck %s
3declare void @call(i32)
4
5define void @add(i32 %init, i32 %n) {
6; CHECK-LABEL: @add(
7; CHECK-NEXT:  entry:
8; CHECK-NEXT:    [[INIT_FROZEN:%.*]] = freeze i32 [[INIT:%.*]]
9; CHECK-NEXT:    br label [[LOOP:%.*]]
10; CHECK:       loop:
11; CHECK-NEXT:    [[I:%.*]] = phi i32 [ [[INIT_FROZEN]], [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
12; CHECK-NEXT:    [[I_NEXT]] = add i32 [[I]], 1
13; CHECK-NEXT:    [[NONSTEP:%.*]] = mul nsw i32 [[I]], 2
14; CHECK-NEXT:    call void @call(i32 [[NONSTEP]])
15; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[I_NEXT]], [[N:%.*]]
16; CHECK-NEXT:    br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
17; CHECK:       exit:
18; CHECK-NEXT:    ret void
19;
20entry:
21  br label %loop
22
23loop:
24  %i = phi i32 [ %init, %entry], [%i.next, %loop ]
25  %i.next = add nsw i32 %i, 1
26  %i.next.fr = freeze i32 %i.next
27  %nonstep = mul nsw i32 %i, 2
28  call void @call(i32 %nonstep)
29  %cond = icmp eq i32 %i.next.fr, %n
30  br i1 %cond, label %loop, label %exit
31
32exit:
33  ret void
34}
35