[PATCH] Canonicalize addrspacecast between different pointer types.

Jingyue Wu jingyue at google.com
Tue May 20 10:18:49 PDT 2014


Hi,

I would like to follow up on this patch because it can simplify some addrspacecast-related optimizations. I recently worked on a patch (http://reviews.llvm.org/D3586) to eliminate unnecessary addrspacecasts from non-generic address spaces to the generic one for the NVPTX backend. For instance, we may want to optimize "load i32* addrspacecast (i64 addrspace(1)* to i32*)" to "load i32 addrspace(1)* bitcast (i64 addrspace(1)* to i32 addrspace(1)*)" because loading from non-generic address spaces is typically faster. If addrspacecasts are "canonicalized" as changing only the address space, the logic in my patch can be simplified a lot: I can simply remove the addrspacecast without introducing the bitcast. 

In general, I believe this canonicalization is beneficial, and would love to see it pushed in. I guess Matt has more examples that can benefit from this transformation. In terms of implementation, I am open to other alternatives such as implementing this canonicalization as a separate pass that can be enabled/disabled by backends. 

Thanks,
Jingyue

http://reviews.llvm.org/D2186






More information about the llvm-commits mailing list