<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 - [IndVarSimplify] wrong code"
href="https://bugs.llvm.org/show_bug.cgi?id=37211">37211</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[IndVarSimplify] wrong code
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paulsson@linux.vnet.ibm.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=20212" name="attach_20212" title="reduced testcase">attachment 20212</a> <a href="attachment.cgi?id=20212&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase
This loop:
lbl_1806: ; preds = %lbl_1806, %entry
%d.0 = phi i16 [ 0, %entry ], [ %dec, %lbl_1806 ]
%dec = add i16 %d.0, -1
%conv2 = mul i16 %dec, %dec
%tobool = icmp eq i16 %conv2, 0
br i1 %tobool, label %if.end, label %lbl_1806
if.end: ; preds = %lbl_1806
%dec.lcssa = phi i16 [ %dec, %lbl_1806 ]
%conv2.lcssa = phi i16 [ %conv2, %lbl_1806 ]
%conv = sext i16 %dec.lcssa to i32
-> *** IR Dump After Induction Variable Simplification ***
; Loop:
lbl_1806: ; preds = %lbl_1806, %entry
%d.0 = phi i16 [ 0, %entry ], [ %dec, %lbl_1806 ]
%dec = add i16 %d.0, -1
%conv2 = mul i16 %dec, %dec
%tobool = icmp eq i16 %conv2, 0
br i1 %tobool, label %if.end, label %lbl_1806
; Exit blocks
if.end: ; preds = %lbl_1806
%conv = sext i16 0 to i32
After the loop, %conv is now sext of constant 0 instead of %dec. My guess is
that IndVarSimplify has thought that the loop must exit when 'mul i16
%dec, %dec' is 0, so therefore %dec is always zero after the loop. However,
since %dec is i16, this happens also when it is -256, and 0 is therefore not
the correct constant after the loop in this case.
bin/clang -w -O3 -march=z13 ./wrong0.i -o ./a.out
Note: this disappears with '-mllvm -disable-licm-promotion'</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>