llvm.org GIT mirror llvm / 91380b7
Fix a bug in the trip-count computation with And/Or. If either of the sides is CouldNotCompute, the resulting exact count must be CouldNotCompute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73920 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 11 years ago
2 changed file(s) with 154 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
29012901 if (L->contains(TBB)) {
29022902 // Both conditions must be true for the loop to continue executing.
29032903 // Choose the less conservative count.
2904 if (BTI0.Exact == CouldNotCompute)
2905 BECount = BTI1.Exact;
2906 else if (BTI1.Exact == CouldNotCompute)
2907 BECount = BTI0.Exact;
2904 if (BTI0.Exact == CouldNotCompute || BTI1.Exact == CouldNotCompute)
2905 BECount = CouldNotCompute;
29082906 else
29092907 BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
29102908 if (BTI0.Max == CouldNotCompute)
29352933 if (L->contains(FBB)) {
29362934 // Both conditions must be false for the loop to continue executing.
29372935 // Choose the less conservative count.
2938 if (BTI0.Exact == CouldNotCompute)
2939 BECount = BTI1.Exact;
2940 else if (BTI1.Exact == CouldNotCompute)
2941 BECount = BTI0.Exact;
2936 if (BTI0.Exact == CouldNotCompute || BTI1.Exact == CouldNotCompute)
2937 BECount = CouldNotCompute;
29422938 else
29432939 BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
29442940 if (BTI0.Max == CouldNotCompute)
0 ; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \
1 ; RUN: | grep {Loop bb7.i: Unpredictable backedge-taken count\\.}
2
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
4
5 %struct.complex = type { float, float }
6 %struct.element = type { i32, i32 }
7 %struct.node = type { %struct.node*, %struct.node*, i32 }
8 @seed = external global i64 ; [#uses=0]
9 @_2E_str = external constant [18 x i8], align 1 ; <[18 x i8]*> [#uses=0]
10 @_2E_str1 = external constant [4 x i8], align 1 ; <[4 x i8]*> [#uses=0]
11 @value = external global float ; [#uses=0]
12 @fixed = external global float ; [#uses=0]
13 @floated = external global float ; [#uses=0]
14 @permarray = external global [11 x i32], align 32 ; <[11 x i32]*> [#uses=0]
15 @pctr = external global i32 ; [#uses=0]
16 @tree = external global %struct.node* ; <%struct.node**> [#uses=0]
17 @stack = external global [4 x i32], align 16 ; <[4 x i32]*> [#uses=0]
18 @cellspace = external global [19 x %struct.element], align 32 ; <[19 x %struct.element]*> [#uses=0]
19 @freelist = external global i32 ; [#uses=0]
20 @movesdone = external global i32 ; [#uses=0]
21 @ima = external global [41 x [41 x i32]], align 32 ; <[41 x [41 x i32]]*> [#uses=0]
22 @imb = external global [41 x [41 x i32]], align 32 ; <[41 x [41 x i32]]*> [#uses=0]
23 @imr = external global [41 x [41 x i32]], align 32 ; <[41 x [41 x i32]]*> [#uses=0]
24 @rma = external global [41 x [41 x float]], align 32 ; <[41 x [41 x float]]*> [#uses=0]
25 @rmb = external global [41 x [41 x float]], align 32 ; <[41 x [41 x float]]*> [#uses=0]
26 @rmr = external global [41 x [41 x float]], align 32 ; <[41 x [41 x float]]*> [#uses=0]
27 @piececount = external global [4 x i32], align 16 ; <[4 x i32]*> [#uses=0]
28 @class = external global [13 x i32], align 32 ; <[13 x i32]*> [#uses=0]
29 @piecemax = external global [13 x i32], align 32 ; <[13 x i32]*> [#uses=0]
30 @puzzl = external global [512 x i32], align 32 ; <[512 x i32]*> [#uses=0]
31 @p = external global [13 x [512 x i32]], align 32 ; <[13 x [512 x i32]]*> [#uses=0]
32 @n = external global i32 ; [#uses=0]
33 @kount = external global i32 ; [#uses=0]
34 @sortlist = external global [5001 x i32], align 32 ; <[5001 x i32]*> [#uses=0]
35 @biggest = external global i32 ; [#uses=0]
36 @littlest = external global i32 ; [#uses=0]
37 @top = external global i32 ; [#uses=0]
38 @z = external global [257 x %struct.complex], align 32 ; <[257 x %struct.complex]*> [#uses=0]
39 @w = external global [257 x %struct.complex], align 32 ; <[257 x %struct.complex]*> [#uses=0]
40 @e = external global [130 x %struct.complex], align 32 ; <[130 x %struct.complex]*> [#uses=0]
41 @zr = external global float ; [#uses=0]
42 @zi = external global float ; [#uses=0]
43
44 declare void @Initrand() nounwind
45
46 declare i32 @Rand() nounwind
47
48 declare void @Try(i32, i32*, i32*, i32*, i32*, i32*) nounwind
49
50 declare i32 @puts(i8* nocapture) nounwind
51
52 declare void @Queens(i32) nounwind
53
54 declare i32 @printf(i8* nocapture, ...) nounwind
55
56 declare i32 @main() nounwind
57
58 declare void @Doit() nounwind
59
60 declare void @Doit_bb7([15 x i32]*, [17 x i32]*, [9 x i32]*) nounwind
61
62 define void @Doit_bb7_2E_i([9 x i32]* %x1, [15 x i32]* %c, [17 x i32]* %b, [9 x i32]* %a, i32* %q, i32* %x1.sub, i32* %b9, i32* %a10, i32* %c11) nounwind {
63 newFuncRoot:
64 br label %bb7.i
65
66 Try.exit.exitStub: ; preds = %bb7.i
67 ret void
68
69 bb.i: ; preds = %bb7.i
70 %tmp = add i32 %j.0.i, 1 ; [#uses=5]
71 store i32 0, i32* %q, align 4
72 %tmp1 = sext i32 %tmp to i64 ; [#uses=1]
73 %tmp2 = getelementptr [9 x i32]* %a, i64 0, i64 %tmp1 ; [#uses=1]
74 %tmp3 = load i32* %tmp2, align 4 ; [#uses=1]
75 %tmp4 = icmp eq i32 %tmp3, 0 ; [#uses=1]
76 br i1 %tmp4, label %bb.i.bb7.i.backedge_crit_edge, label %bb1.i
77
78 bb1.i: ; preds = %bb.i
79 %tmp5 = add i32 %j.0.i, 2 ; [#uses=1]
80 %tmp6 = sext i32 %tmp5 to i64 ; [#uses=1]
81 %tmp7 = getelementptr [17 x i32]* %b, i64 0, i64 %tmp6 ; [#uses=1]
82 %tmp8 = load i32* %tmp7, align 4 ; [#uses=1]
83 %tmp9 = icmp eq i32 %tmp8, 0 ; [#uses=1]
84 br i1 %tmp9, label %bb1.i.bb7.i.backedge_crit_edge, label %bb2.i
85
86 bb2.i: ; preds = %bb1.i
87 %tmp10 = sub i32 7, %j.0.i ; [#uses=1]
88 %tmp11 = sext i32 %tmp10 to i64 ; [#uses=1]
89 %tmp12 = getelementptr [15 x i32]* %c, i64 0, i64 %tmp11 ; [#uses=1]
90 %tmp13 = load i32* %tmp12, align 4 ; [#uses=1]
91 %tmp14 = icmp eq i32 %tmp13, 0 ; [#uses=1]
92 br i1 %tmp14, label %bb2.i.bb7.i.backedge_crit_edge, label %bb3.i
93
94 bb3.i: ; preds = %bb2.i
95 %tmp15 = getelementptr [9 x i32]* %x1, i64 0, i64 1 ; [#uses=1]
96 store i32 %tmp, i32* %tmp15, align 4
97 %tmp16 = sext i32 %tmp to i64 ; [#uses=1]
98 %tmp17 = getelementptr [9 x i32]* %a, i64 0, i64 %tmp16 ; [#uses=1]
99 store i32 0, i32* %tmp17, align 4
100 %tmp18 = add i32 %j.0.i, 2 ; [#uses=1]
101 %tmp19 = sext i32 %tmp18 to i64 ; [#uses=1]
102 %tmp20 = getelementptr [17 x i32]* %b, i64 0, i64 %tmp19 ; [#uses=1]
103 store i32 0, i32* %tmp20, align 4
104 %tmp21 = sub i32 7, %j.0.i ; [#uses=1]
105 %tmp22 = sext i32 %tmp21 to i64 ; [#uses=1]
106 %tmp23 = getelementptr [15 x i32]* %c, i64 0, i64 %tmp22 ; [#uses=1]
107 store i32 0, i32* %tmp23, align 4
108 call void @Try(i32 2, i32* %q, i32* %b9, i32* %a10, i32* %c11, i32* %x1.sub) nounwind
109 %tmp24 = load i32* %q, align 4 ; [#uses=1]
110 %tmp25 = icmp eq i32 %tmp24, 0 ; [#uses=1]
111 br i1 %tmp25, label %bb5.i, label %bb3.i.bb7.i.backedge_crit_edge
112
113 bb5.i: ; preds = %bb3.i
114 %tmp26 = sext i32 %tmp to i64 ; [#uses=1]
115 %tmp27 = getelementptr [9 x i32]* %a, i64 0, i64 %tmp26 ; [#uses=1]
116 store i32 1, i32* %tmp27, align 4
117 %tmp28 = add i32 %j.0.i, 2 ; [#uses=1]
118 %tmp29 = sext i32 %tmp28 to i64 ; [#uses=1]
119 %tmp30 = getelementptr [17 x i32]* %b, i64 0, i64 %tmp29 ; [#uses=1]
120 store i32 1, i32* %tmp30, align 4
121 %tmp31 = sub i32 7, %j.0.i ; [#uses=1]
122 %tmp32 = sext i32 %tmp31 to i64 ; [#uses=1]
123 %tmp33 = getelementptr [15 x i32]* %c, i64 0, i64 %tmp32 ; [#uses=1]
124 store i32 1, i32* %tmp33, align 4
125 br label %bb7.i.backedge
126
127 bb7.i.backedge: ; preds = %bb3.i.bb7.i.backedge_crit_edge, %bb2.i.bb7.i.backedge_crit_edge, %bb1.i.bb7.i.backedge_crit_edge, %bb.i.bb7.i.backedge_crit_edge, %bb5.i
128 br label %bb7.i
129
130 bb7.i: ; preds = %bb7.i.backedge, %newFuncRoot
131 %j.0.i = phi i32 [ 0, %newFuncRoot ], [ %tmp, %bb7.i.backedge ] ; [#uses=8]
132 %tmp34 = load i32* %q, align 4 ; [#uses=1]
133 %tmp35 = icmp eq i32 %tmp34, 0 ; [#uses=1]
134 %tmp36 = icmp ne i32 %j.0.i, 8 ; [#uses=1]
135 %tmp37 = and i1 %tmp35, %tmp36 ; [#uses=1]
136 br i1 %tmp37, label %bb.i, label %Try.exit.exitStub
137
138 bb.i.bb7.i.backedge_crit_edge: ; preds = %bb.i
139 br label %bb7.i.backedge
140
141 bb1.i.bb7.i.backedge_crit_edge: ; preds = %bb1.i
142 br label %bb7.i.backedge
143
144 bb2.i.bb7.i.backedge_crit_edge: ; preds = %bb2.i
145 br label %bb7.i.backedge
146
147 bb3.i.bb7.i.backedge_crit_edge: ; preds = %bb3.i
148 br label %bb7.i.backedge
149 }