[PATCH] Canonicalize addrspacecast between different pointer types.

Matt Arsenault Matthew.Arsenault at amd.com
Tue Jun 3 16:31:31 PDT 2014


On 06/03/2014 04:25 PM, Jingyue Wu wrote:
> Matt,
>
> I think the root cause for this loop is at InstCombineCasts.cpp:1438. The code there considers a GEP with all zero indices as a bitcast, and merges it with CI. While this merging is fine for bitcast, it undoes the canonicalization if CI is addrspacecast.
>
> To fix this issue, I modified the code around there: if CI is addrspacecast and the getelementptr changes the pointer type, do not merge them.
>
> I uploaded my changes to http://reviews.llvm.org/differential/diff/10068/. These changes include:
> * Applied D2186
> * Fixed the infinite loop issue and added the failed test to addrspacecast.ll
> * As discussed offline, I put bitcast before addrspacecast instead of after because I slightly prefer this way.
> * Updated all affected tests. One affected test (@test2_addrspacecast) in memcpy-from-global.ll is actually better optimized because of this canonicalization. See how alloca %T being transformed to alloca [128 x i8]
>
> I am unable to update this diff directly probably because it's not created by me. If my changes conceptually look good to you, I can create a separate revision for further review.
>
> Thanks,
> Jingyue
>
> http://reviews.llvm.org/D2186
>
>
Looks fine to me



More information about the llvm-commits mailing list