<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:kkhoo@perfwizard.com" title="Kay Tiong Khoo <kkhoo@perfwizard.com>"> <span class="fn">Kay Tiong Khoo</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - wrong code for bit shifting integer promotion at -O1 and above on x86_64-linux-gnu"
href="http://llvm.org/bugs/show_bug.cgi?id=17975">bug 17975</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 for bit shifting integer promotion at -O1 and above on x86_64-linux-gnu"
href="http://llvm.org/bugs/show_bug.cgi?id=17975#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - wrong code for bit shifting integer promotion at -O1 and above on x86_64-linux-gnu"
href="http://llvm.org/bugs/show_bug.cgi?id=17975">bug 17975</a>
from <span class="vcard"><a class="email" href="mailto:kkhoo@perfwizard.com" title="Kay Tiong Khoo <kkhoo@perfwizard.com>"> <span class="fn">Kay Tiong Khoo</span></a>
</span></b>
<pre>I think this code creates undefined behavior based on this section of the C
standard:
ยง6.5.7 Bitwise shift operators
3 The integer promotions are performed on each of the operands. The type of
the result is that of the promoted left operand. If the value of the right
operand is negative or is greater than or equal to the width of the promoted
left operand, the behavior is undefined.
...
You're left-shifting an 8-bit value ('c') by 8 (the global 's' is initialized
to zero), so the compiler is free to do anything here.
Note that clang trunk with -O1 is generating the expected rotate-right
instruction here (more about that optimization and handling better-written
source is in <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - wrong code at -Os and above on x86_64-linux-gnu (both 32-bit and 64-bit modes)"
href="show_bug.cgi?id=17732">bug 17732</a>).
Resolving as invalid. Please reopen if you disagree.</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>