Fix typo.
[oota-llvm.git] / test / CodeGen / PowerPC / pr20442.ll
1 ; RUN: llc -mcpu=pwr7 < %s | FileCheck %s
2 target datalayout = "E-m:e-p:32:32-i64:64-n32"
3 target triple = "powerpc-unknown-linux-gnu"
4
5 ; This code would cause code generation like this after PPCCTRLoops ran:
6 ;  %indvar = phi i32 [ 0, %for.body ], [ %indvar.next, %if.then6 ]
7 ;  %j.1.ph13 = phi i32 [ %j.110, %if.then6 ], [ 0, %for.body ], [ 0, %for.body ]
8 ;  %c.0.ph12 = phi i32 [ %dec, %if.then6 ], [ %2, %for.body ], [ %2, %for.body ]
9 ; which would fail verification because the created induction variable does not
10 ; have as many predecessor entries as the other PHIs.
11 ; CHECK-LABEL: @fn1
12 ; CHECK: mtctr
13
14 %struct.anon = type { i32 }
15 %struct.anon.0 = type { i32 }
16
17 @b = common global %struct.anon* null, align 4
18 @a = common global %struct.anon.0* null, align 4
19
20 ; Function Attrs: nounwind readonly uwtable
21 define i32 @fn1() #0 {
22 entry:
23   %0 = load %struct.anon*, %struct.anon** @b, align 4
24   %1 = ptrtoint %struct.anon* %0 to i32
25   %cmp = icmp sgt %struct.anon* %0, null
26   %2 = load %struct.anon.0*, %struct.anon.0** @a, align 4
27   br i1 %cmp, label %for.bodythread-pre-split, label %if.end8
28
29 for.bodythread-pre-split:                         ; preds = %entry
30   %aclass = getelementptr inbounds %struct.anon.0, %struct.anon.0* %2, i32 0, i32 0
31   %.pr = load i32, i32* %aclass, align 4
32   br label %for.body
33
34 for.body:                                         ; preds = %for.bodythread-pre-split, %for.body
35   switch i32 %.pr, label %for.body [
36     i32 0, label %while.body.lr.ph.preheader
37     i32 2, label %while.body.lr.ph.preheader
38   ]
39
40 while.body.lr.ph.preheader:                       ; preds = %for.body, %for.body
41   br label %while.body.lr.ph
42
43 while.body.lr.ph:                                 ; preds = %while.body.lr.ph.preheader, %if.then6
44   %j.1.ph13 = phi i32 [ %j.110.lcssa, %if.then6 ], [ 0, %while.body.lr.ph.preheader ]
45   %c.0.ph12 = phi i32 [ %dec, %if.then6 ], [ %1, %while.body.lr.ph.preheader ]
46   br label %while.body
47
48 while.cond:                                       ; preds = %while.body
49   %cmp2 = icmp slt i32 %inc7, %c.0.ph12
50   br i1 %cmp2, label %while.body, label %if.end8.loopexit
51
52 while.body:                                       ; preds = %while.body.lr.ph, %while.cond
53   %j.110 = phi i32 [ %j.1.ph13, %while.body.lr.ph ], [ %inc7, %while.cond ]
54   %aclass_index = getelementptr inbounds %struct.anon, %struct.anon* %0, i32 %j.110, i32 0
55   %3 = load i32, i32* %aclass_index, align 4
56   %aclass5 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %2, i32 %3, i32 0
57   %4 = load i32, i32* %aclass5, align 4
58   %tobool = icmp eq i32 %4, 0
59   %inc7 = add nsw i32 %j.110, 1
60   br i1 %tobool, label %while.cond, label %if.then6
61
62 if.then6:                                         ; preds = %while.body
63   %j.110.lcssa = phi i32 [ %j.110, %while.body ]
64   %dec = add nsw i32 %c.0.ph12, -1
65   %cmp29 = icmp slt i32 %j.110.lcssa, %dec
66   br i1 %cmp29, label %while.body.lr.ph, label %if.end8.loopexit17
67
68 if.end8.loopexit:                                 ; preds = %while.cond
69   br label %if.end8
70
71 if.end8.loopexit17:                               ; preds = %if.then6
72   br label %if.end8
73
74 if.end8:                                          ; preds = %if.end8.loopexit17, %if.end8.loopexit, %entry
75   ret i32 undef
76 }
77
78 attributes #0 = { nounwind readonly uwtable }
79