1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -canon-freeze -S | FileCheck %s
3 ; A set of tests that have several phi nodes
4 declare void @call(i32)
7 define void @onephi_used(i32 %n, i32 %i.init, i32 %j.init) {
8 ; CHECK-LABEL: @onephi_used(
10 ; CHECK-NEXT: [[I_INIT_FROZEN:%.*]] = freeze i32 [[I_INIT:%.*]]
11 ; CHECK-NEXT: br label [[LOOP:%.*]]
13 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_INIT_FROZEN]], [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
14 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_INIT:%.*]], [[ENTRY]] ], [ [[J_NEXT:%.*]], [[LOOP]] ]
15 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
16 ; CHECK-NEXT: [[J_NEXT]] = add nuw nsw i32 [[J]], -2
17 ; CHECK-NEXT: call void @call(i32 [[I]])
18 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[I_NEXT]], [[N:%.*]]
19 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
21 ; CHECK-NEXT: ret void
26 %i = phi i32 [ %i.init, %entry ], [ %i.next, %loop ]
27 %j = phi i32 [ %j.init, %entry ], [ %j.next, %loop ]
28 %i.next = add nuw nsw i32 %i, 1
29 %j.next = add nuw nsw i32 %j, -2
31 call void @call(i32 %i.fr)
32 %cond = icmp eq i32 %i.next, %n
33 br i1 %cond, label %loop, label %exit
40 define void @twophis_used(i32 %n, i32 %i.init, i32 %j.init) {
41 ; CHECK-LABEL: @twophis_used(
43 ; CHECK-NEXT: br label [[LOOP:%.*]]
45 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_INIT:%.*]], [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
46 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_INIT:%.*]], [[ENTRY]] ], [ [[J_NEXT:%.*]], [[LOOP]] ]
47 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
48 ; CHECK-NEXT: [[J_NEXT]] = add nuw nsw i32 [[J]], -2
49 ; CHECK-NEXT: [[IJ:%.*]] = add i32 [[I]], [[J]]
50 ; CHECK-NEXT: [[IJ_FR:%.*]] = freeze i32 [[IJ]]
51 ; CHECK-NEXT: call void @call(i32 [[IJ_FR]])
52 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[I_NEXT]], [[N:%.*]]
53 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
55 ; CHECK-NEXT: ret void
60 %i = phi i32 [ %i.init, %entry ], [ %i.next, %loop ]
61 %j = phi i32 [ %j.init, %entry ], [ %j.next, %loop ]
62 %i.next = add nuw nsw i32 %i, 1
63 %j.next = add nuw nsw i32 %j, -2
65 %ij.fr = freeze i32 %ij
66 call void @call(i32 %ij.fr)
67 %cond = icmp eq i32 %i.next, %n
68 br i1 %cond, label %loop, label %exit
75 define void @nonindphi_used(i32 %n, i32 %i.init, i32 %j.init, i32 %k.init) {
76 ; CHECK-LABEL: @nonindphi_used(
78 ; CHECK-NEXT: br label [[LOOP:%.*]]
80 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_INIT:%.*]], [[ENTRY:%.*]] ], [ [[I_NEXT:%.*]], [[LOOP]] ]
81 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_INIT:%.*]], [[ENTRY]] ], [ [[J_NEXT:%.*]], [[LOOP]] ]
82 ; CHECK-NEXT: [[K:%.*]] = phi i32 [ [[K_INIT:%.*]], [[ENTRY]] ], [ [[ANY:%.*]], [[LOOP]] ]
83 ; CHECK-NEXT: [[I_NEXT]] = add nuw nsw i32 [[I]], 1
84 ; CHECK-NEXT: [[J_NEXT]] = add nuw nsw i32 [[J]], -2
85 ; CHECK-NEXT: [[IJ:%.*]] = add i32 [[I]], [[J]]
86 ; CHECK-NEXT: [[IJK:%.*]] = add i32 [[IJ]], [[K]]
87 ; CHECK-NEXT: [[IJK_FR:%.*]] = freeze i32 [[IJK]]
88 ; CHECK-NEXT: call void @call(i32 [[IJK_FR]])
89 ; CHECK-NEXT: [[ANY]] = call i32 @call2()
90 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[I_NEXT]], [[N:%.*]]
91 ; CHECK-NEXT: br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
93 ; CHECK-NEXT: ret void
99 %i = phi i32 [ %i.init, %entry ], [ %i.next, %loop ]
100 %j = phi i32 [ %j.init, %entry ], [ %j.next, %loop ]
101 %k = phi i32 [ %k.init, %entry ], [ %any, %loop ]
102 %i.next = add nuw nsw i32 %i, 1
103 %j.next = add nuw nsw i32 %j, -2
105 %ijk = add i32 %ij, %k
106 %ijk.fr = freeze i32 %ijk
107 call void @call(i32 %ijk.fr)
108 %any = call i32 @call2()
109 %cond = icmp eq i32 %i.next, %n
110 br i1 %cond, label %loop, label %exit