[PATCH] Remove seemingly dead InstCombine compare code

Eli Friedman eli.friedman at gmail.com
Thu Aug 15 14:04:24 PDT 2013


On Wed, Aug 14, 2013 at 4:16 PM, Matt Arsenault
<Matthew.Arsenault at amd.com>wrote:

> On 08/12/2013 04:16 PM, Eli Friedman wrote:
>
>> On Mon, Aug 5, 2013 at 3:11 PM, Matt Arsenault
>> <Matthew.Arsenault at amd.com> wrote:
>>
>>>    Add missing check lines
>>>
>>>    test1_noinbounds shows the current behavior. Why wouldn't it be valid?
>>>
>> Because you don't know how X was computed, it could be anything.  For
>> example, it could be "@some_other_zero_int - @G16", an arbitrarily
>> large number which is not 9, but the address would point at a 0.
>>
>> If that's the current behavior, it's a bug.
>>
>> -Eli
>>
>>  I still don't really understand. If you're subtracting the addresses of
> 2 different objects, that's undefined.


In C, you can write it as "(uintptr_t)&some_other_zero_int -
(uintptr_t)&G16".  Subtracting two unsigned ints is never undefined
behavior.


> If you're accessing somewhere outside of the global, that is also
> undefined,
>

This is precisely what inbounds indicates; it we don't have inbounds, the
arithmetic performed by GEP is defined to be wrapping, so nothing is
undefined.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130815/551056ef/attachment.html>


More information about the llvm-commits mailing list