[PATCH] Check address space when optimizing gep+cast

Matt Arsenault Matthew.Arsenault at amd.com
Fri Mar 28 12:07:36 PDT 2014


On 03/28/2014 12:01 PM, Jingyue Wu wrote:
> Fixing PR19270. This issue is blocking a waiting patch of mine that 
> implements the optimization we discussed in 
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-March/071440.html.
>
> visitGetElementPtr in InstructionCombining.cpp gets rid of unnecessary 
> pointer casts in gep (cast X). However, this optimization may change 
> the address space of the result pointer type, and cause type mismatch.
>
> e.g.,
> getelementptr [256 x float]* addrspacecast ([256 x float] 
> addrspace(3)* @array to [256 x float]*), i64 0, i64 %i
> returns a float*, but the optimized instruction
> getelementptr [256 x float] addrspace(3)* @array, i64 0, i64 %i
> returns a float addrspace(3)*
>
> The attached patch disables this optimization when the address space 
> of the source is different from that of the destination.
>
> Jingyue

If we're doing what I suggested and trying to do operations in the 
original address space, then instead of disabling this, why don't you 
make this instead just move the addrspacecast to after the GEP? Do the 
GEP in addrspace(3), and then addrspacecast that.

-Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140328/be336a8b/attachment.html>


More information about the llvm-commits mailing list