<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 - Missing vectorization of loop due to load late in the loop"
href="https://bugs.llvm.org/show_bug.cgi?id=45823">45823</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing vectorization of loop due to load late in the loop
</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>Linux
</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>mikael.holmen@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23456" name="attach_23456" title="bbi-39227-lv.ll">attachment 23456</a> <a href="attachment.cgi?id=23456&action=edit" title="bbi-39227-lv.ll">[details]</a></span>
bbi-39227-lv.ll
Reproduce with
opt -loop-vectorize -S -o - bbi-39227-lv.ll -debug
Result:
LV: Not vectorizing: Found an unidentified PHI %h.15 = phi i32 [ %h.11,
%inner.cond.preheader ], [ %h.1, %inner.body ]
The inner loop body looks like:
inner.body: ; preds =
%inner.cond.preheader, %inner.body
%h.15 = phi i32 [ %h.11, %inner.cond.preheader ], [ %h.1, %inner.body ]
%h.pn4 = phi i32* [ %h, %inner.cond.preheader ], [ %hp.1, %inner.body ]
%j.03 = phi i16 [ 0, %inner.cond.preheader ], [ %j.1, %inner.body ]
%real.02 = phi i32 [ 0, %inner.cond.preheader ], [ %sub, %inner.body ]
%hp.1 = getelementptr inbounds i32, i32* %h.pn4, i64 1
; The loop can get vectorized if the load is placed here...
%h.1 = load i32, i32* %hp.1, align 1
%0 = shl i32 %h.15, 16
%conv7 = ashr exact i32 %0, 16
%add = sub i32 %real.02, %h.15
%sub = add i32 %add, %conv7
%j.1 = add nuw nsw i16 %j.03, 1
; ... but not when it's here.
; %h.1 = load i32, i32* %hp.1, align 1
%cmp3 = icmp ult i16 %j.03, 99
br i1 %cmp3, label %inner.body, label %inner.end
If we move the load
%h.1 = load i32, i32* %hp.1, align 1
earlier in the loop so it's placed directly after the definition of %hp.1, we
instead get:
LV: We can vectorize this loop!
This PR is the result of the following discussion on llvm-dev:
<a href="https://lists.llvm.org/pipermail/llvm-dev/2020-May/141404.html">https://lists.llvm.org/pipermail/llvm-dev/2020-May/141404.html</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>