Skip to content

Commit 0fa7733

Browse files
authored
[LoopInterchange] Improve some tests (NFC) (#156426)
This patch addresses issues in existing test cases that I discovered while working on DependenceAnalysis. Details: - Add `inbounds` to certain `getelementptr` instructions - Add `nuw`/`nsw` to the instructions that update induction variables - Fix incorrect type argument in `getelementptr`.
1 parent cf444ac commit 0fa7733

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

llvm/test/Transforms/LoopInterchange/profitability-vectorization-heuristic.ll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,31 @@ entry:
130130

131131
for.i.header:
132132
%i = phi i64 [ 1, %entry ], [ %i.next, %for.i.inc ]
133-
%i.inc = add i64 %i, 1
133+
%i.inc = add nuw nsw i64 %i, 1
134134
br label %for.j.body
135135

136136
for.j.body:
137137
%j = phi i64 [ 1, %for.i.header ], [ %j.next, %for.j.body ]
138-
%j.dec = add i64 %j, -1
139-
%a.load.index = getelementptr [256 x [256 x float]], ptr @A, i64 0, i64 %i, i64 %j.dec
140-
%b.index = getelementptr [256 x [256 x float]], ptr @B, i64 0, i64 %i, i64 %j
141-
%c.load.index = getelementptr [256 x [256 x float]], ptr @C, i64 0, i64 %i.inc, i64 %j
142-
%c.store.index = getelementptr [256 x [256 x float]], ptr @C, i64 0, i64 %i, i64 %j
138+
%j.dec = add nsw i64 %j, -1
139+
%a.load.index = getelementptr inbounds [256 x [256 x float]], ptr @A, i64 0, i64 %i, i64 %j.dec
140+
%b.index = getelementptr inbounds [256 x [256 x float]], ptr @B, i64 0, i64 %i, i64 %j
141+
%c.load.index = getelementptr inbounds [256 x [256 x float]], ptr @C, i64 0, i64 %i.inc, i64 %j
142+
%c.store.index = getelementptr inbounds [256 x [256 x float]], ptr @C, i64 0, i64 %i, i64 %j
143143
%a = load float, ptr %a.load.index
144144
%b = load float, ptr %b.index
145145
%c0 = load float, ptr %c.load.index
146146
%c1 = load float, ptr %c.store.index
147147
%add.0 = fadd float %a, %b
148-
%a.store.index = getelementptr [256 x [256 x float]], ptr @A, i64 0, i64 %i, i64 %j
148+
%a.store.index = getelementptr inbounds [256 x [256 x float]], ptr @A, i64 0, i64 %i, i64 %j
149149
store float %add.0, ptr %a.store.index
150150
%add.1 = fadd float %c0, %c1
151151
store float %add.1, ptr %c.store.index
152-
%j.next = add i64 %j, 1
152+
%j.next = add nuw nsw i64 %j, 1
153153
%cmp.j = icmp eq i64 %j.next, 256
154154
br i1 %cmp.j, label %for.i.inc, label %for.j.body
155155

156156
for.i.inc:
157-
%i.next = add i64 %i, 1
157+
%i.next = add nuw nsw i64 %i, 1
158158
%cmp.i = icmp eq i64 %i.next, 255
159159
br i1 %cmp.i, label %exit, label %for.i.header
160160

@@ -195,27 +195,27 @@ entry:
195195

196196
for.i.header:
197197
%i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ]
198-
%i.inc = add i64 %i, 1
198+
%i.inc = add nuw nsw i64 %i, 1
199199
br label %for.j.header
200200

201201
for.j.header:
202202
%j = phi i64 [ 0, %for.i.header ], [ %j.inc, %for.j.inc ]
203-
%j.inc = add i64 %j, 1
203+
%j.inc = add nuw nsw i64 %j, 1
204204
br label %for.k.body
205205

206206
for.k.body:
207207
%k = phi i64 [ 0, %for.j.header ], [ %k.inc, %for.k.inc ]
208-
%k.inc = add i64 %k, 1
209-
%k.2 = mul i64 %k, 2
210-
%d.index = getelementptr [256 x [256 x [256 x float]]], ptr @D, i64 0, i64 %i.inc, i64 %j.inc, i64 %k.2
211-
%e.index = getelementptr [256 x [256 x [256 x float]]], ptr @E, i64 0, i64 %i, i64 %j, i64 %k
208+
%k.inc = add nuw nsw i64 %k, 1
209+
%k.2 = mul nuw nsw i64 %k, 2
210+
%d.index = getelementptr inbounds [256 x [256 x [256 x float]]], ptr @D, i64 0, i64 %i.inc, i64 %j.inc, i64 %k.2
211+
%e.index = getelementptr inbounds [256 x [256 x [256 x float]]], ptr @E, i64 0, i64 %i, i64 %j, i64 %k
212212
%d.load = load float, ptr %d.index
213213
store float %d.load, ptr %e.index
214214
%cond = freeze i1 undef
215215
br i1 %cond, label %if.then, label %for.k.inc
216216

217217
if.then:
218-
%d.index2 = getelementptr [256 x [256 x [256 x float]]], ptr @D, i64 0, i64 %i, i64 %j, i64 %k.inc
218+
%d.index2 = getelementptr inbounds [256 x [256 x [256 x float]]], ptr @D, i64 0, i64 %i, i64 %j, i64 %k.inc
219219
store float 1.0, ptr %d.index2
220220
br label %for.k.inc
221221

llvm/test/Transforms/LoopInterchange/profitability-vectorization.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ for.j.body:
6565
%add.2 = fadd float %add.1, %d
6666
%add.3 = fadd float %add.2, %e
6767
%add.4 = fadd float %add.3, %f
68-
%a.1.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @A, i64 %j, i64 %i
68+
%a.1.index = getelementptr nuw inbounds [256 x float], ptr @A, i64 %j, i64 %i
6969
store float %add.4, ptr %a.1.index, align 4
7070
%j.next = add nuw nsw i64 %j, 1
7171
%cmp.j = icmp eq i64 %j.next, 256

0 commit comments

Comments
 (0)