1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ;; Ensure we don't change after value numbering by accidentally deleting the wrong expression.
3 ; RUN: opt -newgvn -S %s | FileCheck %s
4 define void @fn1() local_unnamed_addr #0 {
7 ; CHECK-NEXT: br label [[FOR_COND_PREHEADER:%.*]]
9 ; CHECK-NEXT: br label [[FOR_COND_PREHEADER]]
10 ; CHECK: for.cond.preheader:
11 ; CHECK-NEXT: [[H_031:%.*]] = phi i32 [ 5, [[ENTRY:%.*]] ], [ [[H_127:%.*]], [[WHILE_COND:%.*]] ]
12 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
14 ; CHECK-NEXT: [[H_128:%.*]] = phi i32 [ [[H_031]], [[FOR_COND_PREHEADER]] ], [ [[H_2:%.*]], [[FOR_INC:%.*]] ]
15 ; CHECK-NEXT: br label [[IF_THEN:%.*]]
17 ; CHECK-NEXT: br i1 false, label [[L_LOOPEXIT:%.*]], label [[IF_END:%.*]]
19 ; CHECK-NEXT: br i1 undef, label [[FOR_INC]], label [[IF_END9:%.*]]
21 ; CHECK-NEXT: br label [[FOR_INC]]
23 ; CHECK-NEXT: [[H_2]] = phi i32 [ [[H_128]], [[IF_END]] ], [ 0, [[IF_END9]] ]
24 ; CHECK-NEXT: br i1 undef, label [[WHILE_COND10_LOOPEXIT:%.*]], label [[FOR_BODY]]
25 ; CHECK: while.cond10.loopexit:
26 ; CHECK-NEXT: br label [[WHILE_COND10:%.*]]
27 ; CHECK: while.cond10:
28 ; CHECK-NEXT: [[H_127]] = phi i32 [ [[H_126:%.*]], [[IF_END18:%.*]] ], [ [[H_125:%.*]], [[L:%.*]] ], [ [[H_2]], [[WHILE_COND10_LOOPEXIT]] ]
29 ; CHECK-NEXT: br i1 undef, label [[WHILE_COND]], label [[WHILE_BODY12:%.*]]
30 ; CHECK: while.body12:
31 ; CHECK-NEXT: br i1 undef, label [[IF_END18]], label [[L]]
33 ; CHECK-NEXT: store i8 undef, i8* null
34 ; CHECK-NEXT: br label [[L]]
36 ; CHECK-NEXT: [[H_125]] = phi i32 [ [[H_127]], [[WHILE_BODY12]] ], [ undef, [[L_LOOPEXIT]] ]
37 ; CHECK-NEXT: br i1 undef, label [[WHILE_COND10]], label [[IF_END18]]
39 ; CHECK-NEXT: [[H_126]] = phi i32 [ [[H_125]], [[L]] ], [ [[H_127]], [[WHILE_BODY12]] ]
40 ; CHECK-NEXT: br label [[WHILE_COND10]]
43 br label %for.cond.preheader
45 while.cond: ; preds = %while.cond10
46 br label %for.cond.preheader
48 for.cond.preheader: ; preds = %while.cond, %entry
49 %h.031 = phi i32 [ 5, %entry ], [ %h.127, %while.cond ]
52 for.body: ; preds = %for.inc, %for.cond.preheader
53 %h.128 = phi i32 [ %h.031, %for.cond.preheader ], [ %h.2, %for.inc ]
56 if.then: ; preds = %for.body
57 br i1 false, label %L.loopexit, label %if.end
59 if.end: ; preds = %if.then
60 br i1 undef, label %for.inc, label %if.end9
62 if.end9: ; preds = %if.end
65 for.inc: ; preds = %if.end9, %if.end
66 %h.2 = phi i32 [ %h.128, %if.end ], [ 0, %if.end9 ]
67 br i1 undef, label %while.cond10.loopexit, label %for.body
69 while.cond10.loopexit: ; preds = %for.inc
70 %h.2.lcssa = phi i32 [ %h.2, %for.inc ]
71 br label %while.cond10
73 while.cond10: ; preds = %if.end18, %L, %while.cond10.loopexit
74 %h.127 = phi i32 [ %h.126, %if.end18 ], [ %h.125, %L ], [ %h.2.lcssa, %while.cond10.loopexit ]
75 br i1 undef, label %while.cond, label %while.body12
77 while.body12: ; preds = %while.cond10
78 br i1 undef, label %if.end18, label %L
80 L.loopexit: ; preds = %if.then
83 L: ; preds = %L.loopexit, %while.body12
84 %h.125 = phi i32 [ %h.127, %while.body12 ], [ undef, %L.loopexit ]
85 br i1 undef, label %while.cond10, label %if.end18
87 if.end18: ; preds = %L, %while.body12
88 %h.126 = phi i32 [ %h.125, %L ], [ %h.127, %while.body12 ]
89 br label %while.cond10
93 define void @hoge() local_unnamed_addr #0 {
96 ; CHECK-NEXT: br label [[BB1:%.*]]
98 ; CHECK-NEXT: [[TMP:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[TMP2:%.*]], [[BB1]] ]
99 ; CHECK-NEXT: [[TMP2]] = add nuw nsw i64 [[TMP]], 1
100 ; CHECK-NEXT: br label [[BB1]]
105 bb1: ; preds = %bb1, %bb
106 %tmp = phi i64 [ 0, %bb ], [ %tmp2, %bb1 ]
107 %tmp2 = add nuw nsw i64 %tmp, 1
111 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
114 source_filename = "pr33187-c.ll"
119 ; CHECK-NEXT: store i8* null, i8** null
120 ; CHECK-NEXT: br label [[D:%.*]]
122 ; CHECK-NEXT: [[I:%.*]] = phi i8* [ null, [[B:%.*]] ], [ [[E:%.*]], [[F:%.*]] ]
123 ; CHECK-NEXT: br i1 undef, label [[F]], label [[G:%.*]]
125 ; CHECK-NEXT: store i8* [[I]], i8** null
126 ; CHECK-NEXT: unreachable
128 ; CHECK-NEXT: [[E]] = getelementptr i8, i8* [[I]], i64 1
129 ; CHECK-NEXT: br label [[D]]
132 store i8* null, i8** null
136 %i = phi i8* [ null, %b ], [ %e, %f ]
137 br i1 undef, label %f, label %g
140 %h = phi i8* [ %i, %d ]
141 store i8* %h, i8** null
145 %e = getelementptr i8, i8* %i, i64 1