Use references to attribute groups on the call/invoke instructions.
[oota-llvm.git] / test / Transforms / ScalarRepl / phi-cycle.ll
1 ; RUN: opt -S -scalarrepl-ssa < %s | FileCheck %s
2 ; rdar://10589171
3
4 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-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
6
7 %struct.foo = type { i32, i32 }
8
9 @.str = private unnamed_addr constant [6 x i8] c"x=%d\0A\00", align 1
10
11 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind uwtable {
12 entry:
13   %f = alloca %struct.foo, align 4
14   %x.i = getelementptr inbounds %struct.foo* %f, i64 0, i32 0
15   store i32 1, i32* %x.i, align 4
16   %y.i = getelementptr inbounds %struct.foo* %f, i64 0, i32 1
17   br label %while.cond.i
18
19 ; CHECK: while.cond.i:
20 ; CHECK-NEXT: %tmp = phi i32 [ 1, %entry ], [ %tmp2, %while.cond.backedge.i ]
21 ; CHECK-NEXT: %pos.0.i = phi i32 [ 1, %entry ], [ %xtmp.i, %while.cond.backedge.i ]
22 ; CHECK-NEXT: %left.0.i = phi i32 [ 1, %entry ], [ %dec.i, %while.cond.backedge.i ]
23 ; CHECK-NOT: phi
24 while.cond.i:                                     ; preds = %while.cond.backedge.i, %entry
25   %tmp = phi i32 [ 1, %entry ], [ %tmp2, %while.cond.backedge.i ]
26   %pos.0.i = phi i32 [ 1, %entry ], [ %xtmp.i, %while.cond.backedge.i ]
27   %left.0.i = phi i32 [ 1, %entry ], [ %dec.i, %while.cond.backedge.i ]
28   %cmp.i = icmp sgt i32 %left.0.i, 0
29   br i1 %cmp.i, label %while.body.i, label %while.cond.i.func.exit_crit_edge
30
31 while.cond.i.func.exit_crit_edge:                 ; preds = %while.cond.i
32   br label %func.exit
33
34 while.body.i:                                     ; preds = %while.cond.i
35   %dec.i = add nsw i32 %left.0.i, -1
36   switch i32 1, label %while.body.i.func.exit_crit_edge [
37     i32 0, label %while.cond.backedge.i
38     i32 1, label %sw.bb.i
39   ]
40
41 while.body.i.func.exit_crit_edge:                 ; preds = %while.body.i
42   br label %func.exit
43
44 sw.bb.i:                                          ; preds = %while.body.i
45   %cmp2.i = icmp eq i32 %tmp, 1
46   br i1 %cmp2.i, label %if.then.i, label %if.end.i
47
48 if.then.i:                                        ; preds = %sw.bb.i
49   store i32 %pos.0.i, i32* %x.i, align 4
50   br label %if.end.i
51
52 ; CHECK: if.end.i:
53 ; CHECK-NEXT: %tmp1 = phi i32 [ %pos.0.i, %if.then.i ], [ %tmp, %sw.bb.i ]
54 ; CHECK-NOT: phi
55 if.end.i:                                         ; preds = %if.then.i, %sw.bb.i
56   %tmp1 = phi i32 [ %pos.0.i, %if.then.i ], [ %tmp, %sw.bb.i ]
57   store i32 %tmp1, i32* %y.i, align 4
58   br label %while.cond.backedge.i
59
60 ; CHECK: while.cond.backedge.i:
61 ; CHECK-NEXT: %tmp2 = phi i32 [ %tmp1, %if.end.i ], [ %tmp, %while.body.i ]
62 ; CHECK-NOT: phi
63 while.cond.backedge.i:                            ; preds = %if.end.i, %while.body.i
64   %tmp2 = phi i32 [ %tmp1, %if.end.i ], [ %tmp, %while.body.i ]
65   %xtmp.i = add i32 %pos.0.i, 1
66   br label %while.cond.i
67
68 ; CHECK: func.exit:
69 ; CHECK-NOT: load
70 ; CHECK: %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i64 0, i64 0), i32 %tmp) [[NUW:#[0-9]+]]
71 func.exit:                                        ; preds = %while.body.i.func.exit_crit_edge, %while.cond.i.func.exit_crit_edge
72   %tmp3 = load i32* %x.i, align 4
73   %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i64 0, i64 0), i32 %tmp3) nounwind
74   ret i32 0
75 }
76
77 declare i32 @printf(i8* nocapture, ...) nounwind
78
79 ; CHECK: attributes #0 = { nounwind uwtable }
80 ; CHECK: attributes [[NUW]] = { nounwind }