[LLVMbugs] [Bug 18591] Incorrect optimization of is_simm32 C++ function from HotSpot JVM sources

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 23 08:55:01 PST 2014


Benjamin Kramer <benny.kra at gmail.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
                 CC|                            |benny.kra at gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from Benjamin Kramer <benny.kra at gmail.com> ---
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

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140123/a5e5ba5a/attachment.html>

More information about the llvm-bugs mailing list