<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 - [InstCombine] Miscompile of sext(ashr(shl(trunc())))"
href="https://bugs.llvm.org/show_bug.cgi?id=48343">48343</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstCombine] Miscompile of sext(ashr(shl(trunc())))
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>meheff@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Example failing input:
define i10 @test(i10 %i) {
%a = trunc i10 %i to i3
%b = shl i3 %a, 2
%c = ashr i3 %b, 2
%d = sext i3 %c to i10
ret i10 %d
}
Bad code after optimizations:
$ opt -S --instcombine /tmp/fail.ll
; ModuleID = '/tmp/fail.ll'
source_filename = "/tmp/fail.ll"
define i10 @test(i10 %i) {
%d1 = shl i10 %i, 1
%d = ashr exact i10 %d1, 1
ret i10 %d
}
This should be shifting left by 9 then shifting right by 9, but (I think) the
optimization tries to create a 9 of type i3 which is the source of the bug:
<a href="https://github.com/llvm/llvm-project/blob/8cdf4920c47ddd3d60bdc3298f525512d483ce65/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1526">https://github.com/llvm/llvm-project/blob/8cdf4920c47ddd3d60bdc3298f525512d483ce65/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1526</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>