• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -o - -mtriple=x86_64-apple-macosx | FileCheck %s
2; Test case for the recoloring of broken hints.
3; This is tricky to have something reasonably small to kick this optimization since
4; it requires that spliting and spilling occur.
5; The bottom line is that this test case is fragile.
6; This was reduced from the make_list function from the llvm-testsuite:
7; SingleSource/Benchmarks/McGill/chomp.c
8
9target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
10target triple = "x86_64-apple-macosx10.9.0"
11
12%struct._list = type { i32*, %struct._list* }
13
14@ncol = external global i32, align 4
15@nrow = external global i32, align 4
16
17declare noalias i32* @copy_data()
18
19declare noalias i8* @malloc(i64)
20
21declare i32 @get_value()
22
23declare i32 @in_wanted(i32* nocapture readonly)
24
25declare noalias i32* @make_data()
26
27; CHECK-LABEL: make_list:
28; Function prologue.
29; CHECK: pushq
30; CHECK: subq ${{[0-9]+}}, %rsp
31; Move the first argument (%data) into a temporary register.
32; It will not survive the call to malloc otherwise.
33; CHECK: movq %rdi, [[ARG1:%r[0-9a-z]+]]
34; CHECK: callq _malloc
35; Compute %data - 1 as used for load in land.rhs.i (via the variable  %indvars.iv.next.i).
36; CHECK: addq $-4, [[ARG1]]
37; We use to produce a useless copy here and move %data in another temporary register.
38; CHECK-NOT: movq [[ARG1]]
39; End of the first basic block.
40; CHECK: .p2align
41; Now check that %data is used in an address computation.
42; CHECK: leaq ([[ARG1]]
43define %struct._list* @make_list(i32* nocapture readonly %data, i32* nocapture %value, i32* nocapture %all) {
44entry:
45  %call = tail call i8* @malloc(i64 16)
46  %next = getelementptr inbounds i8, i8* %call, i64 8
47  %tmp = bitcast i8* %next to %struct._list**
48  %tmp2 = bitcast i8* %call to %struct._list*
49  %.pre78 = load i32, i32* @ncol, align 4
50  br label %for.cond1.preheader
51
52for.cond1.preheader:                              ; preds = %for.inc32, %entry
53  %tmp4 = phi i32 [ %.pre78, %entry ], [ 0, %for.inc32 ]
54  %current.077 = phi %struct._list* [ %tmp2, %entry ], [ %current.1.lcssa, %for.inc32 ]
55  %cmp270 = icmp eq i32 %tmp4, 0
56  br i1 %cmp270, label %for.inc32, label %for.body3
57
58for.body3:                                        ; preds = %if.end31, %for.cond1.preheader
59  %current.173 = phi %struct._list* [ %current.2, %if.end31 ], [ %current.077, %for.cond1.preheader ]
60  %row.172 = phi i32 [ %row.3, %if.end31 ], [ 0, %for.cond1.preheader ]
61  %col.071 = phi i32 [ %inc, %if.end31 ], [ 0, %for.cond1.preheader ]
62  %call4 = tail call i32* @make_data()
63  %tmp5 = load i32, i32* @ncol, align 4
64  %tobool14.i = icmp eq i32 %tmp5, 0
65  br i1 %tobool14.i, label %while.cond.i, label %while.body.lr.ph.i
66
67while.body.lr.ph.i:                               ; preds = %for.body3
68  %tmp6 = sext i32 %tmp5 to i64
69  br label %while.body.i
70
71while.body.i:                                     ; preds = %while.body.i, %while.body.lr.ph.i
72  %indvars.iv.i = phi i64 [ %tmp6, %while.body.lr.ph.i ], [ %indvars.iv.next.i, %while.body.i ]
73  %indvars.iv.next.i = add nsw i64 %indvars.iv.i, -1
74  %tmp9 = trunc i64 %indvars.iv.next.i to i32
75  %tobool.i = icmp eq i32 %tmp9, 0
76  br i1 %tobool.i, label %while.cond.i, label %while.body.i
77
78while.cond.i:                                     ; preds = %land.rhs.i, %while.body.i, %for.body3
79  %indvars.iv.i64 = phi i64 [ %indvars.iv.next.i65, %land.rhs.i ], [ 0, %for.body3 ], [ %tmp6, %while.body.i ]
80  %indvars.iv.next.i65 = add nsw i64 %indvars.iv.i64, -1
81  %tmp10 = trunc i64 %indvars.iv.i64 to i32
82  %tobool.i66 = icmp eq i32 %tmp10, 0
83  br i1 %tobool.i66, label %if.else, label %land.rhs.i
84
85land.rhs.i:                                       ; preds = %while.cond.i
86  %arrayidx.i67 = getelementptr inbounds i32, i32* %call4, i64 %indvars.iv.next.i65
87  %tmp11 = load i32, i32* %arrayidx.i67, align 4
88  %arrayidx2.i68 = getelementptr inbounds i32, i32* %data, i64 %indvars.iv.next.i65
89  %tmp12 = load i32, i32* %arrayidx2.i68, align 4
90  %cmp.i69 = icmp eq i32 %tmp11, %tmp12
91  br i1 %cmp.i69, label %while.cond.i, label %equal_data.exit
92
93equal_data.exit:                                  ; preds = %land.rhs.i
94  %cmp3.i = icmp slt i32 %tmp10, 1
95  br i1 %cmp3.i, label %if.else, label %if.then
96
97if.then:                                          ; preds = %equal_data.exit
98  %next7 = getelementptr inbounds %struct._list, %struct._list* %current.173, i64 0, i32 1
99  %tmp14 = load %struct._list*, %struct._list** %next7, align 8
100  %next12 = getelementptr inbounds %struct._list, %struct._list* %tmp14, i64 0, i32 1
101  store %struct._list* null, %struct._list** %next12, align 8
102  %tmp15 = load %struct._list*, %struct._list** %next7, align 8
103  %tmp16 = load i32, i32* %value, align 4
104  %cmp14 = icmp eq i32 %tmp16, 1
105  %.tmp16 = select i1 %cmp14, i32 0, i32 %tmp16
106  %tmp18 = load i32, i32* %all, align 4
107  %tmp19 = or i32 %tmp18, %.tmp16
108  %tmp20 = icmp eq i32 %tmp19, 0
109  br i1 %tmp20, label %if.then19, label %if.end31
110
111if.then19:                                        ; preds = %if.then
112  %call21 = tail call i32 @in_wanted(i32* %call4)
113  br label %if.end31
114
115if.else:                                          ; preds = %equal_data.exit, %while.cond.i
116  %cmp26 = icmp eq i32 %col.071, 0
117  %.row.172 = select i1 %cmp26, i32 0, i32 %row.172
118  %sub30 = add nsw i32 %tmp5, -1
119  br label %if.end31
120
121if.end31:                                         ; preds = %if.else, %if.then19, %if.then
122  %col.1 = phi i32 [ %sub30, %if.else ], [ 0, %if.then ], [ 0, %if.then19 ]
123  %row.3 = phi i32 [ %.row.172, %if.else ], [ %row.172, %if.then ], [ 0, %if.then19 ]
124  %current.2 = phi %struct._list* [ %current.173, %if.else ], [ %tmp15, %if.then ], [ %tmp15, %if.then19 ]
125  %inc = add nsw i32 %col.1, 1
126  %tmp25 = load i32, i32* @ncol, align 4
127  %cmp2 = icmp eq i32 %inc, %tmp25
128  br i1 %cmp2, label %for.cond1.for.inc32_crit_edge, label %for.body3
129
130for.cond1.for.inc32_crit_edge:                    ; preds = %if.end31
131  %.pre79 = load i32, i32* @nrow, align 4
132  br label %for.inc32
133
134for.inc32:                                        ; preds = %for.cond1.for.inc32_crit_edge, %for.cond1.preheader
135  %tmp26 = phi i32 [ %.pre79, %for.cond1.for.inc32_crit_edge ], [ 0, %for.cond1.preheader ]
136  %current.1.lcssa = phi %struct._list* [ %current.2, %for.cond1.for.inc32_crit_edge ], [ %current.077, %for.cond1.preheader ]
137  %row.1.lcssa = phi i32 [ %row.3, %for.cond1.for.inc32_crit_edge ], [ 0, %for.cond1.preheader ]
138  %inc33 = add nsw i32 %row.1.lcssa, 1
139  %cmp = icmp eq i32 %inc33, %tmp26
140  br i1 %cmp, label %for.end34, label %for.cond1.preheader
141
142for.end34:                                        ; preds = %for.inc32
143  %.pre = load %struct._list*, %struct._list** %tmp, align 8
144  ret %struct._list* %.pre
145}
146