llvm.org GIT mirror llvm / df4caba
Merging r214423: ------------------------------------------------------------------------ r214423 | hfinkel | 2014-07-31 12:13:38 -0700 (Thu, 31 Jul 2014) | 9 lines Fix ScalarEvolutionExpander when creating a PHI in a block with duplicate predecessors It seems that when I fixed this, almost exactly a year ago, I did not quite do it correctly. When we have duplicate block predecessors, we can indeed not have different incoming values for the same block, but we *must* have duplicate entries. So, instead of skipping the duplicates, we explicitly add the duplicate incoming values. Fixes PR20442. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@214684 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 5 years ago
2 changed file(s) with 84 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
14421442 Constant *One = ConstantInt::get(Ty, 1);
14431443 for (pred_iterator HPI = HPB; HPI != HPE; ++HPI) {
14441444 BasicBlock *HP = *HPI;
1445 if (!PredSeen.insert(HP))
1445 if (!PredSeen.insert(HP)) {
1446 // There must be an incoming value for each predecessor, even the
1447 // duplicates!
1448 CanonicalIV->addIncoming(CanonicalIV->getIncomingValueForBlock(HP), HP);
14461449 continue;
1450 }
14471451
14481452 if (L->contains(HP)) {
14491453 // Insert a unit add instruction right before the terminator
0 ; RUN: llc -mcpu=pwr7 < %s | FileCheck %s
1 target datalayout = "E-m:e-p:32:32-i64:64-n32"
2 target triple = "powerpc-unknown-linux-gnu"
3
4 ; This code would cause code generation like this after PPCCTRLoops ran:
5 ; %indvar = phi i32 [ 0, %for.body ], [ %indvar.next, %if.then6 ]
6 ; %j.1.ph13 = phi i32 [ %j.110, %if.then6 ], [ 0, %for.body ], [ 0, %for.body ]
7 ; %c.0.ph12 = phi i32 [ %dec, %if.then6 ], [ %2, %for.body ], [ %2, %for.body ]
8 ; which would fail verification because the created induction variable does not
9 ; have as many predecessor entries as the other PHIs.
10 ; CHECK-LABEL: @fn1
11 ; CHECK: mtctr
12
13 %struct.anon = type { i32 }
14 %struct.anon.0 = type { i32 }
15
16 @b = common global %struct.anon* null, align 4
17 @a = common global %struct.anon.0* null, align 4
18
19 ; Function Attrs: nounwind readonly uwtable
20 define i32 @fn1() #0 {
21 entry:
22 %0 = load %struct.anon** @b, align 4
23 %1 = ptrtoint %struct.anon* %0 to i32
24 %cmp = icmp sgt %struct.anon* %0, null
25 %2 = load %struct.anon.0** @a, align 4
26 br i1 %cmp, label %for.bodythread-pre-split, label %if.end8
27
28 for.bodythread-pre-split: ; preds = %entry
29 %aclass = getelementptr inbounds %struct.anon.0* %2, i32 0, i32 0
30 %.pr = load i32* %aclass, align 4
31 br label %for.body
32
33 for.body: ; preds = %for.bodythread-pre-split, %for.body
34 switch i32 %.pr, label %for.body [
35 i32 0, label %while.body.lr.ph.preheader
36 i32 2, label %while.body.lr.ph.preheader
37 ]
38
39 while.body.lr.ph.preheader: ; preds = %for.body, %for.body
40 br label %while.body.lr.ph
41
42 while.body.lr.ph: ; preds = %while.body.lr.ph.preheader, %if.then6
43 %j.1.ph13 = phi i32 [ %j.110.lcssa, %if.then6 ], [ 0, %while.body.lr.ph.preheader ]
44 %c.0.ph12 = phi i32 [ %dec, %if.then6 ], [ %1, %while.body.lr.ph.preheader ]
45 br label %while.body
46
47 while.cond: ; preds = %while.body
48 %cmp2 = icmp slt i32 %inc7, %c.0.ph12
49 br i1 %cmp2, label %while.body, label %if.end8.loopexit
50
51 while.body: ; preds = %while.body.lr.ph, %while.cond
52 %j.110 = phi i32 [ %j.1.ph13, %while.body.lr.ph ], [ %inc7, %while.cond ]
53 %aclass_index = getelementptr inbounds %struct.anon* %0, i32 %j.110, i32 0
54 %3 = load i32* %aclass_index, align 4
55 %aclass5 = getelementptr inbounds %struct.anon.0* %2, i32 %3, i32 0
56 %4 = load i32* %aclass5, align 4
57 %tobool = icmp eq i32 %4, 0
58 %inc7 = add nsw i32 %j.110, 1
59 br i1 %tobool, label %while.cond, label %if.then6
60
61 if.then6: ; preds = %while.body
62 %j.110.lcssa = phi i32 [ %j.110, %while.body ]
63 %dec = add nsw i32 %c.0.ph12, -1
64 %cmp29 = icmp slt i32 %j.110.lcssa, %dec
65 br i1 %cmp29, label %while.body.lr.ph, label %if.end8.loopexit17
66
67 if.end8.loopexit: ; preds = %while.cond
68 br label %if.end8
69
70 if.end8.loopexit17: ; preds = %if.then6
71 br label %if.end8
72
73 if.end8: ; preds = %if.end8.loopexit17, %if.end8.loopexit, %entry
74 ret i32 undef
75 }
76
77 attributes #0 = { nounwind readonly uwtable }
78