<div dir="ltr">Hi Matt, <div><br></div><div>I actually think it should go to lib/Transforms/InstCombine when it gets generalized. Also, <span style="font-family:arial,sans-serif;font-size:13px">TTI</span> would need to expose which address space is generic and whether such optimization would benefit at all. <div>
<br></div><div>Jingyue</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 31, 2014 at 2:00 PM, Matt Arsenault <span dir="ltr"><<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
  This looks like it doesn't handle vectors of pointers, although that's probably not very important.<br>
<br>
  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?<br>
<br>
<br>
================<br>
Comment at: lib/Target/NVPTX/NVPTXFavorNonGenericAddrSpaces.cpp:67-72<br>
@@ +66,8 @@<br>
+<br>
+  Value *Src = Cast->getOperand(0);<br>
+  PointerType *SrcTy = cast<PointerType>(Src->getType());<br>
+  PointerType *DestTy = cast<PointerType>(Cast->getType());<br>
+  // We cannot remove the addrspacecast if the element type changes.<br>
+  if (SrcTy->getElementType() != DestTy->getElementType())<br>
+    return false;<br>
+<br>
----------------<br>
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 (<a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131118/195642.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131118/195642.html</a>) 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.<br>

<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D3235" target="_blank">http://llvm-reviews.chandlerc.com/D3235</a><br>
</blockquote></div><br></div>