[llvm-bugs] [Bug 25986] The add instruction is incorrectly folded into icmp when there is an overflow by instcombine

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 31 17:22:08 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25986

David Majnemer <david.majnemer at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |david.majnemer at gmail.com
          Component|new bugs                    |Scalar Optimizations
         Resolution|---                         |INVALID
            Product|new-bugs                    |libraries

--- Comment #1 from David Majnemer <david.majnemer at gmail.com> ---
Hi Yuanrui,

I do not believe InstCombine is wrong here.

The value you chose for '%j' is 'i32 2147483647'.
The add instruction in '%inc' is 'add nsw i32 %j, 1'.  Notice the 'nsw' flag on
the add instruction, it means that '%inc' is poison if it sign overflows or
sign underflows (see http://llvm.org/docs/LangRef.html#poisonvalues)

This means that we have the following dynamic values:
%j = i32 2147483647
%inc = i32 poison
%cmp = i1 poison
%conv = i32 poison

If you want signed overflow/underflow to be well defined, remove the nsw flag
from the add instruction.

-- 
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/20160101/c8cc0414/attachment.html>


More information about the llvm-bugs mailing list