[PATCH] Removing unnecessary addrspacecasts from non-generic address spaces to the generic address space

Matt Arsenault Matthew.Arsenault at amd.com
Mon Mar 31 14:00:52 PDT 2014


  This looks like it doesn't handle vectors of pointers, although that's probably not very important.

  I don't see anything tying this to NVPTX except the use of 0 for generic. Where should this go when generalized? Put it in lib/CodeGen and add getGenericAddressSpace() to TTI?


================
Comment at: lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp:67-72
@@ +66,8 @@
+
+  Value *Src = Cast->getOperand(0);
+  PointerType *SrcTy = cast<PointerType>(Src->getType());
+  PointerType *DestTy = cast<PointerType>(Cast->getType());
+  // We cannot remove the addrspacecast if the element type changes.
+  if (SrcTy->getElementType() != DestTy->getElementType())
+    return false;
+
----------------
If the element type changes, you can still do it, but you'll need to do the bitcast separately. I had a patch a while ago (http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131118/195642.html) to canonicalize to splitting the bitcast and addrspacecast into separate operations. It might be better to handle it that way than trying to figure it out here.


http://llvm-reviews.chandlerc.com/D3235



More information about the llvm-commits mailing list