[PATCH] Don't constant fold bitcast/ptrtoint/inttoptr combinations without datalayout

Eli Friedman eli.friedman at gmail.com
Tue Jul 16 18:38:04 PDT 2013


On Tue, Jul 16, 2013 at 6:18 PM, Matt Arsenault <arsenm2 at gmail.com> wrote:
> On Jul 16, 2013, at 18:02 , Eli Friedman <eli.friedman at gmail.com> wrote:
>>
>> If SrcTy and MidTy have the same address-space, we know they have the
>> same size; shouldn't we constant-fold even if we don't know what that
>> size is?
>>
>
> I was thinking that for a while, but the original code would only fold if the intermediate integer was at least as big as the pointer size, so this was trying to match that behavior. It could constant fold even if the middle integer size is unknown, but that would change the behavior if the middle integer was smaller (I'm not sure why you would ever want that though).

That applies to folding inttoptr+ptrtoint, but I fail to see how it
applies to folding bitcast+ptrtoint.

-Eli




More information about the llvm-commits mailing list