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

Jingyue Wu jingyue at google.com
Mon Mar 31 15:46:38 PDT 2014



================
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;
+
----------------
Matt Arsenault wrote:
> 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.
I looked at your diff (http://llvm-reviews.chandlerc.com/D2186) and your conversation. They look very interesting to me. If that canonicialization pass landed, we could just similarly hoist addrspacecast from bitcast as what we did to GEP (or even this hoisting to InstCombine). 


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



More information about the llvm-commits mailing list