<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - Loop vectorizer introduces bad "undef""
href="https://llvm.org/bugs/show_bug.cgi?id=24738">24738</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop vectorizer introduces bad "undef"
</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>normal
</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>mattias.v.eriksson@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, nrotem@apple.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=14851" name="attach_14851" title="Reduced reproducer">attachment 14851</a> <a href="attachment.cgi?id=14851&action=edit" title="Reduced reproducer">[details]</a></span>
Reduced reproducer
I think this is a bug in the fix to <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - loop vectorizer borks phi node"
href="show_bug.cgi?id=14725">Bug 14725</a>.
With the attached file if we run:
opt -S -licm -loop-vectorize -O1 -o /dev/null bugpoint-reduced-simplified.ll
-print-after-all -print-before-all
The loop vectorizer does this transformation:
*** IR Dump Before Loop Vectorization ***
define void @TEST__MAIN() {
%_tmp52 = call i16 @foo(i16 0)
%_tmp53 = load i16*, i16** undef
br label %bb1
bb1: ; preds = %bb1, %0
%i.22.0 = phi i16 [ undef, %0 ], [ %_tmp55, %bb1 ]
%_tmp55 = add i16 %i.22.0, 1
%_tmp59 = icmp slt i16 %_tmp55, 40
br i1 %_tmp59, label %bb1, label %bb4.preheader
bb4.preheader: ; preds = %bb1
%_tmp52.lcssa = phi i16 [ %_tmp52, %bb1 ]
store i16 %_tmp52, i16* %_tmp53
%_tmp67 = load i16*, i16** undef
br label %bb4
bb4: ; preds = %bb4.preheader,
%bb4
br i1 false, label %bb4, label %bb6
bb6: ; preds = %bb4
store i16 %_tmp52.lcssa, i16* %_tmp67
ret void
}
*** IR Dump After Loop Vectorization ***
define void @TEST__MAIN() {
%_tmp52 = call i16 @foo(i16 0)
%_tmp53 = load i16*, i16** undef
%min.iters.check = icmp ult i32 1, 4
br i1 %min.iters.check, label %scalar.ph, label %min.iters.checked
min.iters.checked: ; preds = %0
br i1 true, label %middle.block, label %vector.ph
vector.ph: ; preds = %min.iters.checked
br label %vector.body
vector.body: ; preds = %vector.body,
%vector.ph
%index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%1 = trunc i32 %index to i16
%broadcast.splatinsert = insertelement <4 x i16> undef, i16 %1, i32 0
%broadcast.splat = shufflevector <4 x i16> %broadcast.splatinsert, <4 x i16>
undef, <4 x i32> zeroinitializer
%induction = add <4 x i16> %broadcast.splat, <i16 0, i16 1, i16 2, i16 3>
%2 = add <4 x i16> %induction, <i16 1, i16 1, i16 1, i16 1>
%3 = icmp slt <4 x i16> %2, <i16 40, i16 40, i16 40, i16 40>
%index.next = add i32 %index, 4
%4 = icmp eq i32 %index.next, 0
br i1 %4, label %middle.block, label %vector.body, !llvm.loop !0
middle.block: ; preds = %vector.body,
%min.iters.checked
%resume.val = phi i32 [ 0, %min.iters.checked ], [ 0, %vector.body ]
%trunc.resume.val = phi i16 [ undef, %min.iters.checked ], [ 0, %vector.body
]
%cmp.n = icmp eq i32 1, %resume.val
br i1 %cmp.n, label %bb4.preheader, label %scalar.ph
scalar.ph: ; preds = %middle.block, %0
%bc.resume.val = phi i32 [ %resume.val, %middle.block ], [ 0, %0 ]
%bc.trunc.resume.val = phi i16 [ %trunc.resume.val, %middle.block ], [ undef,
%0 ]
br label %bb1
bb1: ; preds = %bb1, %scalar.ph
%i.22.0 = phi i16 [ %bc.trunc.resume.val, %scalar.ph ], [ %_tmp55, %bb1 ]
%_tmp55 = add i16 %i.22.0, 1
%_tmp59 = icmp slt i16 %_tmp55, 40
br i1 %_tmp59, label %bb1, label %bb4.preheader, !llvm.loop !3
bb4.preheader: ; preds = %middle.block, %bb1
%_tmp52.lcssa = phi i16 [ %_tmp52, %bb1 ], [ undef, %middle.block ]
The problem is at the last line. The phi-node has a new incoming value that is
undef, but in this case it should be the same as the first incoming value.
The new "undef" is added in fixLCSSAPHIs() in LoopVectorize.cpp.</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>