<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:benny.kra@gmail.com" title="Benjamin Kramer <benny.kra@gmail.com>"> <span class="fn">Benjamin Kramer</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Incorrect optimization of is_simm32 C++ function from HotSpot JVM sources"
href="http://llvm.org/bugs/show_bug.cgi?id=18591">bug 18591</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;">CC</td>
<td>
</td>
<td>benny.kra@gmail.com
</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 - Incorrect optimization of is_simm32 C++ function from HotSpot JVM sources"
href="http://llvm.org/bugs/show_bug.cgi?id=18591#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - Incorrect optimization of is_simm32 C++ function from HotSpot JVM sources"
href="http://llvm.org/bugs/show_bug.cgi?id=18591">bug 18591</a>
from <span class="vcard"><a class="email" href="mailto:benny.kra@gmail.com" title="Benjamin Kramer <benny.kra@gmail.com>"> <span class="fn">Benjamin Kramer</span></a>
</span></b>
<pre>Sadly this is not really a miscompilation but yet another instance of undefined
behavior being optimized away.
min_simm(32) compiles down to "return -INT_MIN;", which is undefined.
max_simm(32) compiles down to "return INT_MIN-1;", also undefined.
A simple fix would be to change the intptr_t(1) instances to uintptr_t(1),
unsigned overflow is defined and you'll get the intended results. You can also
globally disable this kind of optimization with -fno-strict-overflow or
-fwrapv. Clang has a tool to detect undefined behavior at runtime, try
-fsanitize=undefined.</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>