[LLVMdev] instcombine Question
Dan Gohman
gohman at apple.com
Thu Jul 17 09:43:09 PDT 2008
On Jul 16, 2008, at 1:32 PM, David Greene wrote:
> I see instcombine doing something I'm not sure is right.
>
> Incoming, I have this:
>
> %r29 = ptrtoint [71 x i64]* %"t$3" to i64 ; <i64> [#uses=1]
> %r30 = inttoptr i64 %r29 to i64* ; <i64*> [#uses=1]
> store i64 72057594037927936, i64* %r30, align 8
>
> Outgoing, I have this:
>
> %r30 = getelementptr [71 x i64]* %"t$3", i32 0, i32 0 ; <i64*>
> [#uses=1]
> store i64 72057594037927936, i64* %r30, align 16
>
> I believe the alignment on the outgoing store is wrong, but my
> question
> concerns the optimization of the ptrtoint / intoptr to a gep. Is this
> optimization allowed to pun the pointer type like this or should
> there be
> a bitcast to i64* in there somewhere?
Implicit punning of pointer types in registers is not permitted. The
above
getelementptr isn't doing that though. The first index of a GEP is the
one that just adds to the pointer value and doesn't change the type. The
second index goes into the pointee type -- the array -- so the result
is i64*.
Dan
More information about the llvm-dev
mailing list