<html>
<head>
<base href="http://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 --- - InstCombine: '(x lshr C1) udiv C2 --> x udiv (C2 << C1)' incorrect if C2<<C1 overflows"
href="http://llvm.org/bugs/show_bug.cgi?id=21255">21255</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>InstCombine: '(x lshr C1) udiv C2 --> x udiv (C2 << C1)' incorrect if C2<<C1 overflows
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nunoplopes@sapo.pt
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following transformation in InstCombiner::visitUDiv() is incorrect if
C2<<C1 overflows (and btw correct otherwise):
; (x lshr C1) udiv C2 --> x udiv (C2 << C1)
%Op0 = lshr %X, C1
%r = udiv %Op0, C2
=>
%r = udiv %X, (C2 << C1)
Done: 1
ERROR: Domain of definedness of Target is smaller than Source's for i2 %r
Example:
%X i2 = 0x0 (0)
C1 i2 = 0x1 (1)
C2 i2 = 0x2 (2, -2)
%Op0 i2 = 0x0 (0)
Source value: 0x0 (0)
Target value: undef
And bypassing the undef case:
Pre: ((C2 << C1) != 0)
%Op0 = lshr exact %X, C1
%r = udiv %Op0, C2
=>
%r = udiv %X, (C2 << C1)
ERROR: Mismatch in values of i4 %r
Example:
%X i4 = 0x2 (2)
C1 i4 = 0x1 (1)
C2 i4 = 0x9 (9, -7)
%Op0 i4 = 0x1 (1)
Source value: 0x0 (0)
Target value: 0x1 (1)
And finally we have:
Pre: WillNotOverflowUnsignedShl(C2, C1)
%Op0 = lshr %X, C1
%r = udiv %Op0, C2
=>
%r = udiv %X, (C2 << C1)
Done
Optimization is correct!</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>