<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Another GEP inbound with negative offset generated by loop vectorizer"
href="https://bugs.llvm.org/show_bug.cgi?id=48127">48127</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Another GEP inbound with negative offset generated by loop vectorizer
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>liuz@cs.utah.edu
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>This one shares the same symptom with <a class="bz_bug_link
bz_status_NEW "
title="NEW - GEP inbound with negative offset generated by loop vectorizer"
href="show_bug.cgi?id=48126">bug #48126</a> and might be duplicated.
However, both the code and the commandline are different from #48126, so I am
listing this bug separately.
The source comes from test case:
test/Transforms/LoopVectorize/interleaved-accesses.ll.
define void @PR27626_4(i32 *%a, i32 %x, i32 %y, i32 %z, i64 %n) {
entry:
br label %for.body
for.body:
%i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
%i_plus_1 = add i64 %i, 1
%a_i = getelementptr inbounds i32, i32* %a, i64 %i
%a_i_plus_1 = getelementptr inbounds i32, i32* %a, i64 %i_plus_1
store i32 %x, i32* %a_i, align 4
store i32 %y, i32* %a_i, align 4
store i32 %z, i32* %a_i_plus_1, align 4
%i.next = add nuw nsw i64 %i, 2
%cond = icmp slt i64 %i.next, %n
br i1 %cond, label %for.body, label %for.end
for.end:
ret void
}
Below is the vectorized function after calling opt with the arguments listed in
the test case (-loop-vectorize -instcombine -force-vector-width=4
-force-vector-interleave=1 -enable-interleaved-mem-accesses=true
-runtime-memory-check-threshold=24).
define void @PR27626_4(i32* %a, i32 %x, i32 %y, i32 %z, i64 %n) {
entry:
%0 = icmp sgt i64 %n, 2
%smax = select i1 %0, i64 %n, i64 2
%1 = add nsw i64 %smax, -1
%2 = lshr i64 %1, 1
%3 = add nuw nsw i64 %2, 1
%min.iters.check = icmp ult i64 %1, 6
br i1 %min.iters.check, label %scalar.ph, label %vector.ph
vector.ph: ; preds = %entry
%n.vec = and i64 %3, 9223372036854775804
%ind.end = shl nuw i64 %n.vec, 1
%broadcast.splatinsert = insertelement <4 x i32> undef, i32 %y, i32 0
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32>
undef, <4 x i32> zeroinitializer
%broadcast.splatinsert1 = insertelement <4 x i32> undef, i32 %z, i32 0
%broadcast.splat2 = shufflevector <4 x i32> %broadcast.splatinsert1, <4 x
i32> undef, <4 x i32> zeroinitializer
br label %vector.body
vector.body: ; preds = %vector.body,
%vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%offset.idx = shl i64 %index, 1
%4 = or i64 %offset.idx, 2
%5 = or i64 %offset.idx, 4
%6 = or i64 %offset.idx, 6
%7 = or i64 %offset.idx, 1
%8 = getelementptr inbounds i32, i32* %a, i64 %offset.idx
%9 = getelementptr inbounds i32, i32* %a, i64 %4
%10 = getelementptr inbounds i32, i32* %a, i64 %5
%11 = getelementptr inbounds i32, i32* %a, i64 %6
%12 = getelementptr inbounds i32, i32* %a, i64 -1
store i32 %x, i32* %8, align 4
store i32 %x, i32* %9, align 4
store i32 %x, i32* %10, align 4
store i32 %x, i32* %11, align 4
%13 = getelementptr inbounds i32, i32* %12, i64 %7
%14 = bitcast i32* %13 to <8 x i32>*
%interleaved.vec = shufflevector <4 x i32> %broadcast.splat, <4 x i32>
%broadcast.splat2, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3,
i32 7>
store <8 x i32> %interleaved.vec, <8 x i32>* %14, align 4
%index.next = add i64 %index, 4
%15 = icmp eq i64 %index.next, %n.vec
br i1 %15, label %middle.block, label %vector.body, !llvm.loop !0
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %3, %n.vec
br i1 %cmp.n, label %for.end, label %scalar.ph
scalar.ph: ; preds = %middle.block,
%entry
%bc.resume.val = phi i64 [ %ind.end, %middle.block ], [ 0, %entry ]
br label %for.body
for.body: ; preds = %for.body,
%scalar.ph
%i = phi i64 [ %i.next, %for.body ], [ %bc.resume.val, %scalar.ph ]
%i_plus_1 = or i64 %i, 1
%a_i = getelementptr inbounds i32, i32* %a, i64 %i
%a_i_plus_1 = getelementptr inbounds i32, i32* %a, i64 %i_plus_1
store i32 %y, i32* %a_i, align 4
store i32 %z, i32* %a_i_plus_1, align 4
%i.next = add nuw nsw i64 %i, 2
%cond = icmp slt i64 %i.next, %n
br i1 %cond, label %for.body, label %for.end, !llvm.loop !2
for.end: ; preds = %middle.block,
%for.body
ret void
}
!0 = distinct !{!0, !1}
!1 = !{!"llvm.loop.isvectorized", i32 1}
!2 = distinct !{!2, !3, !1}
!3 = !{!"llvm.loop.unroll.runtime.disable"}
Here %12 is a generated gep inbound with negative offset. The source in this
transformation is more defined than target.
Alive2: <a href="https://alive2.llvm.org/ce/z/eYwaaU">https://alive2.llvm.org/ce/z/eYwaaU</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>