[llvm] r216523 - InstCombine: Optimize GEP's involving ptrtointbetter

Nuno Lopes nunoplopes at sapo.pt
Fri Aug 29 06:29:05 PDT 2014


> On Thu, Aug 28, 2014 at 2:44 PM, Nuno Lopes <nunoplopes at sapo.pt> wrote:
>
> On 27 August 2014 06:16, David Majnemer <david.majnemer at gmail.com> wrote:
> Author: majnemer
> Date: Wed Aug 27 00:16:04 2014
> New Revision: 216523
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216523&view=rev
> Log:
> InstCombine: Optimize GEP's involving ptrtoint better
>
>
> Hi David,
>
> I've done a bisect and this commit broke out test-suite bot:
>
> http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/8059
>
> The big problem is that the test "result" is just an MD5. :(
>
> I'm investigating.
>
> cheers,
> --renato
>
>
> I tried to specify this transformation in Alive.  The transformation 
> supports more complex cases, but I get a failure even for the simplest 
> case:
>
> $ ./alive.py < gep.opt
> Precondition: true
> %0 = ptrtoint i1* %Y
> %1 = sub i64 0, %0
> %r = getelementptr i1* %X, %1
>  =>
> %0 = ptrtoint i1* %Y
> %2 = ptrtoint * %X to i64
> %3 = sub %2, %0
> %r = inttoptr %3 to *
>
>
> ERROR: Mismatch in values of i1* %r
>
> Example:
> %Y i1* = 18446744073709551615 (0xffffffffffffffffL)
> %0 i64 = 18446744073709551615 (0xffffffffffffffffL)
> %1 i64 = 1 (0x1)
> %X i1* = 0 (0x0)
> %2 i64 = 0 (0x0)
> %3 i64 = 1 (0x1)
> Source value: 64 (0x40)
> Target value: 1 (0x1)
>
> Note that the counterexample is assuming pointer-size=8 bits.
> Let me know if I can help with debugging the transformation. (I may be 
> missing some precondition; I just quickly glanced through your patch)
>
>
> Hi Nuno,
>
> I believe Alive isn't ready for getelementptr:
>
> ----------------------------------------
> Optimization: 1
> Precondition: true
> %gep = getelementptr i8* %A, i64 1
> %ret = ptrtoint i8* %gep to i64
>   =>
> %ptrtoint = ptrtoint i8* %A to i64
> %ret = add i64 %ptrtoint, 1
>
>
> ERROR: Mismatch in values of i64 %ret
>
> Example:
> %A i8* = 0 (0x0)
> %gep i8* = 64 (0x40)
> %ptrtoint i64 = 0 (0x0)
> Source value: 64 (0x40)
> Target value: 1 (0x1)
>
> %gep should not be 64.

Wow, that's sad :)
I'll be back from vacations next week and I'll start fixing these things by 
then.  The support for pointers and memory instructions is still quite 
incomplete.

Nuno 




More information about the llvm-commits mailing list