1 ; RUN: opt < %s -disable-output "-passes=print<ddg>" 2>&1 | FileCheck %s
3 ; CHECK-LABEL: 'DDG' for loop 'test1.for.body':
4 ; CHECK: Node Address:[[N1:0x[0-9a-f]*]]:single-instruction
5 ; CHECK-NEXT: Instructions:
6 ; CHECK-NEXT: %i.02 = phi i64 [ %inc, %test1.for.body ], [ 0, %test1.for.body.preheader ]
8 ; CHECK-NEXT: [def-use] to [[N2:0x[0-9a-f]*]]
9 ; CHECK-NEXT: [def-use] to [[N3:0x[0-9a-f]*]]
10 ; CHECK-NEXT: [def-use] to [[N4:0x[0-9a-f]*]]
12 ; CHECK: Node Address:[[N4]]:single-instruction
13 ; CHECK-NEXT: Instructions:
14 ; CHECK-NEXT: %arrayidx = getelementptr inbounds float, float* %b, i64 %i.02
16 ; CHECK-NEXT: [def-use] to [[N5:0x[0-9a-f]*]]
18 ; CHECK: Node Address:[[N5]]:single-instruction
19 ; CHECK-NEXT: Instructions:
20 ; CHECK-NEXT: %0 = load float, float* %arrayidx, align 4
22 ; CHECK-NEXT: [def-use] to [[N6:0x[0-9a-f]*]]
24 ; CHECK: Node Address:[[N7:0x[0-9a-f]*]]:single-instruction
25 ; CHECK-NEXT: Instructions:
26 ; CHECK-NEXT: %conv = uitofp i64 %n to float
28 ; CHECK-NEXT: [def-use] to [[N6]]
30 ; CHECK: Node Address:[[N6]]:single-instruction
31 ; CHECK-NEXT: Instructions:
32 ; CHECK-NEXT: %add = fadd float %0, %conv
34 ; CHECK-NEXT: [def-use] to [[N8:0x[0-9a-f]*]]
36 ; CHECK: Node Address:[[N3]]:single-instruction
37 ; CHECK-NEXT: Instructions:
38 ; CHECK-NEXT: %arrayidx1 = getelementptr inbounds float, float* %a, i64 %i.02
40 ; CHECK-NEXT: [def-use] to [[N8]]
42 ; CHECK: Node Address:[[N8]]:single-instruction
43 ; CHECK-NEXT: Instructions:
44 ; CHECK-NEXT: store float %add, float* %arrayidx1, align 4
45 ; CHECK-NEXT: Edges:none!
47 ; CHECK: Node Address:[[N2]]:single-instruction
48 ; CHECK-NEXT: Instructions:
49 ; CHECK-NEXT: %inc = add i64 %i.02, 1
51 ; CHECK-NEXT: [def-use] to [[N9:0x[0-9a-f]*]]
52 ; CHECK-NEXT: [def-use] to [[N1]]
54 ; CHECK: Node Address:[[N9]]:single-instruction
55 ; CHECK-NEXT: Instructions:
56 ; CHECK-NEXT: %exitcond = icmp ne i64 %inc, %n
58 ; CHECK-NEXT: [def-use] to [[N10:0x[0-9a-f]*]]
60 ; CHECK: Node Address:[[N10]]:single-instruction
61 ; CHECK-NEXT: Instructions:
62 ; CHECK-NEXT: br i1 %exitcond, label %test1.for.body, label %for.end.loopexit
63 ; CHECK-NEXT: Edges:none!
65 ;; No memory dependencies.
66 ;; void test1(unsigned long n, float * restrict a, float * restrict b) {
67 ;; for (unsigned long i = 0; i < n; i++)
71 define void @test1(i64 %n, float* noalias %a, float* noalias %b) {
73 %exitcond1 = icmp ne i64 0, %n
74 br i1 %exitcond1, label %test1.for.body, label %for.end
76 test1.for.body: ; preds = %entry, %test1.for.body
77 %i.02 = phi i64 [ %inc, %test1.for.body ], [ 0, %entry ]
78 %arrayidx = getelementptr inbounds float, float* %b, i64 %i.02
79 %0 = load float, float* %arrayidx, align 4
80 %conv = uitofp i64 %n to float
81 %add = fadd float %0, %conv
82 %arrayidx1 = getelementptr inbounds float, float* %a, i64 %i.02
83 store float %add, float* %arrayidx1, align 4
84 %inc = add i64 %i.02, 1
85 %exitcond = icmp ne i64 %inc, %n
86 br i1 %exitcond, label %test1.for.body, label %for.end
88 for.end: ; preds = %test1.for.body, %entry
93 ; CHECK-LABEL: 'DDG' for loop 'test2.for.body':
94 ; CHECK: Node Address:[[N1:0x[0-9a-f]*]]:single-instruction
95 ; CHECK-NEXT: Instructions:
96 ; CHECK-NEXT: %i.02 = phi i64 [ %inc, %test2.for.body ], [ 0, %test2.for.body.preheader ]
98 ; CHECK-NEXT: [def-use] to [[N2:0x[0-9a-f]*]]
99 ; CHECK-NEXT: [def-use] to [[N3:0x[0-9a-f]*]]
100 ; CHECK-NEXT: [def-use] to [[N4:0x[0-9a-f]*]]
101 ; CHECK-NEXT: [def-use] to [[N5:0x[0-9a-f]*]]
103 ; CHECK: Node Address:[[N5]]:single-instruction
104 ; CHECK-NEXT: Instructions:
105 ; CHECK-NEXT: %arrayidx = getelementptr inbounds float, float* %b, i64 %i.02
107 ; CHECK-NEXT: [def-use] to [[N6:0x[0-9a-f]*]]
109 ; CHECK: Node Address:[[N6]]:single-instruction
110 ; CHECK-NEXT: Instructions:
111 ; CHECK-NEXT: %0 = load float, float* %arrayidx, align 4
113 ; CHECK-NEXT: [def-use] to [[N7:0x[0-9a-f]*]]
115 ; CHECK: Node Address:[[N4]]:single-instruction
116 ; CHECK-NEXT: Instructions:
117 ; CHECK-NEXT: %arrayidx1 = getelementptr inbounds float, float* %a, i64 %i.02
119 ; CHECK-NEXT: [def-use] to [[N8:0x[0-9a-f]*]]
121 ; CHECK: Node Address:[[N8]]:single-instruction
122 ; CHECK-NEXT: Instructions:
123 ; CHECK-NEXT: %1 = load float, float* %arrayidx1, align 4
125 ; CHECK-NEXT: [def-use] to [[N7]]
126 ; CHECK-NEXT: [memory] to [[N9:0x[0-9a-f]*]]
128 ; CHECK: Node Address:[[N7]]:single-instruction
129 ; CHECK-NEXT: Instructions:
130 ; CHECK-NEXT: %add = fadd float %0, %1
132 ; CHECK-NEXT: [def-use] to [[N9]]
134 ; CHECK: Node Address:[[N3]]:single-instruction
135 ; CHECK-NEXT: Instructions:
136 ; CHECK-NEXT: %arrayidx2 = getelementptr inbounds float, float* %a, i64 %i.02
138 ; CHECK-NEXT: [def-use] to [[N9]]
140 ; CHECK: Node Address:[[N9]]:single-instruction
141 ; CHECK-NEXT: Instructions:
142 ; CHECK-NEXT: store float %add, float* %arrayidx2, align 4
143 ; CHECK-NEXT: Edges:none!
145 ; CHECK: Node Address:[[N2]]:single-instruction
146 ; CHECK-NEXT: Instructions:
147 ; CHECK-NEXT: %inc = add i64 %i.02, 1
149 ; CHECK-NEXT: [def-use] to [[N10:0x[0-9a-f]*]]
150 ; CHECK-NEXT: [def-use] to [[N1]]
152 ; CHECK: Node Address:[[N10]]:single-instruction
153 ; CHECK-NEXT: Instructions:
154 ; CHECK-NEXT: %exitcond = icmp ne i64 %inc, %n
156 ; CHECK-NEXT: [def-use] to [[N11:0x[0-9a-f]*]]
158 ; CHECK: Node Address:[[N11]]:single-instruction
159 ; CHECK-NEXT: Instructions:
160 ; CHECK-NEXT: br i1 %exitcond, label %test2.for.body, label %for.end.loopexit
161 ; CHECK-NEXT: Edges:none!
163 ;; Loop-independent memory dependencies.
164 ;; void test2(unsigned long n, float * restrict a, float * restrict b) {
165 ;; for (unsigned long i = 0; i < n; i++)
166 ;; a[i] = b[i] + a[i];
169 define void @test2(i64 %n, float* noalias %a, float* noalias %b) {
171 %exitcond1 = icmp ne i64 0, %n
172 br i1 %exitcond1, label %test2.for.body, label %for.end
174 test2.for.body: ; preds = %entry, %test2.for.body
175 %i.02 = phi i64 [ %inc, %test2.for.body ], [ 0, %entry ]
176 %arrayidx = getelementptr inbounds float, float* %b, i64 %i.02
177 %0 = load float, float* %arrayidx, align 4
178 %arrayidx1 = getelementptr inbounds float, float* %a, i64 %i.02
179 %1 = load float, float* %arrayidx1, align 4
180 %add = fadd float %0, %1
181 %arrayidx2 = getelementptr inbounds float, float* %a, i64 %i.02
182 store float %add, float* %arrayidx2, align 4
183 %inc = add i64 %i.02, 1
184 %exitcond = icmp ne i64 %inc, %n
185 br i1 %exitcond, label %test2.for.body, label %for.end
187 for.end: ; preds = %test2.for.body, %entry