1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=newgvn -S %s | FileCheck %s
3 ; Ensure we do not incorrect do phi of ops
4 source_filename = "/Users/dannyb/sources/llvm-clean/debug-build/pr33305.c"
5 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-apple-macosx10.12.0"
8 @a = common global i32 0, align 4
9 @b = local_unnamed_addr global ptr @a, align 8
10 @e = local_unnamed_addr global i32 -1, align 4
11 @g = local_unnamed_addr global i32 1, align 4
12 @c = common local_unnamed_addr global i32 0, align 4
13 @f = common local_unnamed_addr global i32 0, align 4
14 @h = common local_unnamed_addr global i32 0, align 4
15 @str = private unnamed_addr constant [5 x i8] c"fine\00"
16 @str.2 = private unnamed_addr constant [8 x i8] c"Screwed\00"
18 ; Function Attrs: nounwind optsize ssp uwtable
19 define i32 @main() local_unnamed_addr #0 {
22 ; CHECK-NEXT: [[DOTPR_I:%.*]] = load i32, ptr @c, align 4, !tbaa [[TBAA3:![0-9]+]]
23 ; CHECK-NEXT: [[CMP13_I:%.*]] = icmp slt i32 [[DOTPR_I]], 1
24 ; CHECK-NEXT: br i1 [[CMP13_I]], label [[FOR_COND1_PREHEADER_LR_PH_I:%.*]], label [[ENTRY_FOR_END9_I_CRIT_EDGE:%.*]]
25 ; CHECK: entry.for.end9.i_crit_edge:
26 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, ptr @h, align 4, !tbaa [[TBAA3]]
27 ; CHECK-NEXT: br label [[FOR_END9_I:%.*]]
28 ; CHECK: for.cond1.preheader.lr.ph.i:
29 ; CHECK-NEXT: [[G_PROMOTED14_I:%.*]] = load i32, ptr @g, align 4, !tbaa [[TBAA3]]
30 ; CHECK-NEXT: br label [[FOR_COND1_PREHEADER_I:%.*]]
31 ; CHECK: for.cond1.preheader.i:
32 ; CHECK-NEXT: [[INC816_I:%.*]] = phi i32 [ [[DOTPR_I]], [[FOR_COND1_PREHEADER_LR_PH_I]] ], [ [[INC8_I:%.*]], [[FOR_INC7_I:%.*]] ]
33 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[G_PROMOTED14_I]], [[FOR_COND1_PREHEADER_LR_PH_I]] ], [ 0, [[FOR_INC7_I]] ]
34 ; CHECK-NEXT: br label [[FOR_BODY3_I:%.*]]
36 ; CHECK-NEXT: [[TMP1:%.*]] = phi i1 [ false, [[FOR_COND1_PREHEADER_I]] ], [ true, [[LOR_END_I:%.*]] ]
37 ; CHECK-NEXT: [[INC12_I:%.*]] = phi i32 [ 0, [[FOR_COND1_PREHEADER_I]] ], [ [[INC_I:%.*]], [[LOR_END_I]] ]
38 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP0]], [[FOR_COND1_PREHEADER_I]] ], [ 0, [[LOR_END_I]] ]
39 ; CHECK-NEXT: [[TOBOOL_I:%.*]] = icmp ne i32 [[TMP2]], 0
40 ; CHECK-NEXT: [[OR_COND_I:%.*]] = and i1 [[TMP1]], [[TOBOOL_I]]
41 ; CHECK-NEXT: br i1 [[OR_COND_I]], label [[LOR_END_I]], label [[LOR_RHS_I:%.*]]
43 ; CHECK-NEXT: [[LNOT_I:%.*]] = xor i1 [[TOBOOL_I]], true
44 ; CHECK-NEXT: [[LNOT_EXT_I:%.*]] = zext i1 [[LNOT_I]] to i32
45 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr @e, align 4, !tbaa [[TBAA3]]
46 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[TMP3]], [[LNOT_EXT_I]]
47 ; CHECK-NEXT: store i32 [[XOR_I]], ptr @e, align 4, !tbaa [[TBAA3]]
48 ; CHECK-NEXT: br label [[LOR_END_I]]
50 ; CHECK-NEXT: [[INC_I]] = add nuw nsw i32 [[INC12_I]], 1
51 ; CHECK-NEXT: [[EXITCOND_I:%.*]] = icmp eq i32 [[INC_I]], 2
52 ; CHECK-NEXT: br i1 [[EXITCOND_I]], label [[FOR_INC7_I]], label [[FOR_BODY3_I]]
54 ; CHECK-NEXT: [[INC8_I]] = add nsw i32 [[INC816_I]], 1
55 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp slt i32 [[INC816_I]], 0
56 ; CHECK-NEXT: br i1 [[CMP_I]], label [[FOR_COND1_PREHEADER_I]], label [[FOR_COND_FOR_END9_CRIT_EDGE_I:%.*]]
57 ; CHECK: for.cond.for.end9_crit_edge.i:
58 ; CHECK-NEXT: store i32 0, ptr @g, align 4, !tbaa [[TBAA3]]
59 ; CHECK-NEXT: store i32 2, ptr @h, align 4, !tbaa [[TBAA3]]
60 ; CHECK-NEXT: store i32 [[INC8_I]], ptr @c, align 4, !tbaa [[TBAA3]]
61 ; CHECK-NEXT: br label [[FOR_END9_I]]
63 ; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ [[DOTPRE]], [[ENTRY_FOR_END9_I_CRIT_EDGE]] ], [ 2, [[FOR_COND_FOR_END9_CRIT_EDGE_I]] ]
64 ; CHECK-NEXT: [[TMP5:%.*]] = load ptr, ptr @b, align 8, !tbaa [[TBAA7:![0-9]+]]
65 ; CHECK-NEXT: store i32 [[TMP4]], ptr [[TMP5]], align 4, !tbaa [[TBAA3]]
66 ; CHECK-NEXT: [[TMP6:%.*]] = load i32, ptr @e, align 4, !tbaa [[TBAA3]]
67 ; CHECK-NEXT: [[CMP10_I:%.*]] = icmp slt i32 [[TMP6]], -1
68 ; CHECK-NEXT: br i1 [[CMP10_I]], label [[IF_THEN_I:%.*]], label [[FN1_EXIT:%.*]]
70 ; CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr @f, align 4, !tbaa [[TBAA3]]
71 ; CHECK-NEXT: store i32 [[TMP7]], ptr [[TMP5]], align 4, !tbaa [[TBAA3]]
72 ; CHECK-NEXT: br label [[FN1_EXIT]]
74 ; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr @a, align 4, !tbaa [[TBAA3]]
75 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TMP8]], 0
76 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
78 ; CHECK-NEXT: [[PUTS2:%.*]] = tail call i32 @puts(ptr @str.2)
79 ; CHECK-NEXT: tail call void @abort() #[[ATTR3:[0-9]+]]
80 ; CHECK-NEXT: unreachable
82 ; CHECK-NEXT: [[PUTS:%.*]] = tail call i32 @puts(ptr @str)
83 ; CHECK-NEXT: ret i32 0
86 %.pr.i = load i32, ptr @c, align 4, !tbaa !3
87 %cmp13.i = icmp slt i32 %.pr.i, 1
88 br i1 %cmp13.i, label %for.cond1.preheader.lr.ph.i, label %entry.for.end9.i_crit_edge
90 entry.for.end9.i_crit_edge: ; preds = %entry
91 %.pre = load i32, ptr @h, align 4, !tbaa !3
94 for.cond1.preheader.lr.ph.i: ; preds = %entry
95 %g.promoted14.i = load i32, ptr @g, align 4, !tbaa !3
96 br label %for.cond1.preheader.i
98 for.cond1.preheader.i: ; preds = %for.inc7.i, %for.cond1.preheader.lr.ph.i
99 %inc816.i = phi i32 [ %.pr.i, %for.cond1.preheader.lr.ph.i ], [ %inc8.i, %for.inc7.i ]
100 %0 = phi i32 [ %g.promoted14.i, %for.cond1.preheader.lr.ph.i ], [ 0, %for.inc7.i ]
101 br label %for.body3.i
103 for.body3.i: ; preds = %lor.end.i, %for.cond1.preheader.i
104 %1 = phi i1 [ false, %for.cond1.preheader.i ], [ true, %lor.end.i ]
105 %inc12.i = phi i32 [ 0, %for.cond1.preheader.i ], [ %inc.i, %lor.end.i ]
106 %2 = phi i32 [ %0, %for.cond1.preheader.i ], [ 0, %lor.end.i ]
107 %tobool.i = icmp ne i32 %2, 0
108 %or.cond.i = and i1 %1, %tobool.i
109 br i1 %or.cond.i, label %lor.end.i, label %lor.rhs.i
111 lor.rhs.i: ; preds = %for.body3.i
112 %lnot.i = xor i1 %tobool.i, true
113 %lnot.ext.i = zext i1 %lnot.i to i32
114 %3 = load i32, ptr @e, align 4, !tbaa !3
115 %xor.i = xor i32 %3, %lnot.ext.i
116 store i32 %xor.i, ptr @e, align 4, !tbaa !3
119 lor.end.i: ; preds = %lor.rhs.i, %for.body3.i
120 %inc.i = add nuw nsw i32 %inc12.i, 1
121 %exitcond.i = icmp eq i32 %inc.i, 2
122 br i1 %exitcond.i, label %for.inc7.i, label %for.body3.i
124 for.inc7.i: ; preds = %lor.end.i
125 %inc8.i = add nsw i32 %inc816.i, 1
126 %cmp.i = icmp slt i32 %inc816.i, 0
127 br i1 %cmp.i, label %for.cond1.preheader.i, label %for.cond.for.end9_crit_edge.i
129 for.cond.for.end9_crit_edge.i: ; preds = %for.inc7.i
130 store i32 0, ptr @g, align 4, !tbaa !3
131 store i32 2, ptr @h, align 4, !tbaa !3
132 store i32 %inc8.i, ptr @c, align 4, !tbaa !3
135 for.end9.i: ; preds = %entry.for.end9.i_crit_edge, %for.cond.for.end9_crit_edge.i
136 %4 = phi i32 [ %.pre, %entry.for.end9.i_crit_edge ], [ 2, %for.cond.for.end9_crit_edge.i ]
137 %5 = load ptr, ptr @b, align 8, !tbaa !7
138 store i32 %4, ptr %5, align 4, !tbaa !3
139 %6 = load i32, ptr @e, align 4, !tbaa !3
140 %cmp10.i = icmp slt i32 %6, -1
141 br i1 %cmp10.i, label %if.then.i, label %fn1.exit
143 if.then.i: ; preds = %for.end9.i
144 %7 = load i32, ptr @f, align 4, !tbaa !3
145 store i32 %7, ptr %5, align 4, !tbaa !3
148 fn1.exit: ; preds = %if.then.i, %for.end9.i
149 %8 = load i32, ptr @a, align 4, !tbaa !3
150 %tobool = icmp eq i32 %8, 0
151 br i1 %tobool, label %if.end, label %if.then
153 if.then: ; preds = %fn1.exit
154 %puts2 = tail call i32 @puts(ptr @str.2)
155 tail call void @abort() #3
158 if.end: ; preds = %fn1.exit
159 %puts = tail call i32 @puts(ptr @str)
163 ; Function Attrs: noreturn nounwind optsize
164 declare void @abort() local_unnamed_addr #1
166 ; Function Attrs: nounwind
167 declare i32 @puts(ptr nocapture readonly) local_unnamed_addr #2
169 attributes #0 = { nounwind optsize ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
170 attributes #1 = { noreturn nounwind optsize "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
171 attributes #2 = { nounwind }
172 attributes #3 = { noreturn nounwind optsize }
174 !llvm.module.flags = !{!0, !1}
177 !0 = !{i32 1, !"wchar_size", i32 4}
178 !1 = !{i32 7, !"PIC Level", i32 2}
179 !2 = !{!"clang version 5.0.0"}
180 !3 = !{!4, !4, i64 0}
181 !4 = !{!"int", !5, i64 0}
182 !5 = !{!"omnipotent char", !6, i64 0}
183 !6 = !{!"Simple C/C++ TBAA"}
184 !7 = !{!8, !8, i64 0}
185 !8 = !{!"any pointer", !5, i64 0}