<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:davide@freebsd.org" title="Davide Italiano <davide@freebsd.org>"> <span class="fn">Davide Italiano</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - wrong code at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes)"
href="https://llvm.org/bugs/show_bug.cgi?id=30708">bug 30708</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - wrong code at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes)"
href="https://llvm.org/bugs/show_bug.cgi?id=30708#c8">Comment # 8</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - wrong code at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes)"
href="https://llvm.org/bugs/show_bug.cgi?id=30708">bug 30708</a>
from <span class="vcard"><a class="email" href="mailto:davide@freebsd.org" title="Davide Italiano <davide@freebsd.org>"> <span class="fn">Davide Italiano</span></a>
</span></b>
<pre>This code exhibits undefined behaviour.
Just before instcombine (but after inlining and other many passes) main()
contains the following basica block:
.split: ; preds = %0
%cmp.i.us20 = icmp ugt i32 53, 1
%shr.i.us21 = lshr i32 1, 53
%cmp624.i.us22 = zext i1 %cmp.i.us20 to i32
%conv4.i.us23 = or i32 %cmp624.i.us22, %shr.i.us21
%. = select i1 %tobool8.us46.i, i32 0, i32 1
store i32 1, i32* @c, align 4
store i32 %., i32* @a, align 4
store i32 %conv4.i.us23, i32* @b, align 4
%tmp = load i32, i32* @b, align 4
call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]*
@.str, i32 0, i32 0), i32 %tmp)
ret void
This instruction:
%shr.i.us21 = lshr i32 1, 53
has UB as we're trying to shift right > 32, that gets folded into `undef` by
instcombine, and the next `or i32 %cmp624.i.us22 undef` gets in turn folded
into -1. That's the `-1` value that's subsequently stored, loaded, and printed.</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>