[PATCH] [NVPTX] kernel pointer arguments point to the global address space

Jingyue Wu jingyue at google.com
Tue Jun 2 15:59:29 PDT 2015


================
Comment at: lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp:40
@@ +39,3 @@
+//      %input4 = addrspacecast float addrspace(1)* %input3 to float*
+//      %v = load float, float* %input4, align 4
+//      ...
----------------
jingyue wrote:
> jholewinski wrote:
> > Isn't it possible that an optimization would remove all of these casts before NVVMFavorNonGenericAddrSpaces runs?  I know we control the pass pipeline in the backend, but I worry about these pass ordering constraints.
> Not sure. Removing bitcast is fine for NVPTXFavorNonGenericAddrSpace. Why would any pass remove addrspacecast? addrspacecast has a richer semantics -- it changes the address space of a pointer and accessing pointers in different address spaces are not necessarily as fast. If any pass would want to remove an addrspacecast, it should reason about the performance effects of that too. 
Your concern makes more sense to me if we replace `llvm.nvvm.ptr.gen.to.*` with addrspacecast. In that case, this pass would addrspacecasts value back and forth, e.g., 
```
t1 = cast t0 to global
t2 = cast t1 to generic
```
Then, it's reasonable for some optimizations to cancel such addrspacecast pairs. 

Maybe not in this patch, we can merge this pass and NVPTXFavorNonGeneric into something like NVPTXTypeInference? That should prevent other passes from messing up the intermediate code (besides the name becomes fancier :) How does that sound to you?

http://reviews.llvm.org/D10154

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list