<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 19/03/14 17:40, Matt Arsenault
      wrote:<br>
    </div>
    <blockquote cite="mid:5329D685.2010404@amd.com" type="cite">
      <pre wrap="">

Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -517,27 +517,35 @@
       IC.getDataLayout()->getTypeSizeInBits(DestPTy))
     return 0;
 
+  // Don't introduce casts between pointers to different address spaces. We
+  // can't use the addrspacecast instruction in this case since, depending on
+  // the target, addrspacecast may not be a no-op cast.
+  if (SrcPTy->isPointerTy() && DestPTy->isPointerTy() &&
+      cast<PointerType>(SrcPTy)->getAddressSpace() !=
+      cast<PointerType>(DestPTy)->getAddressSpace())
+    return 0;
+
</pre>
    </blockquote>
    <blockquote cite="mid:5329D685.2010404@amd.com" type="cite"> <br>
      Right above here is a check leftover from when bitcast was allowed
      if the pointers were the same size. You should update that and
      replace it with this.<br>
    </blockquote>
    <br>
    Are you talking about this code?<br>
    <blockquote>  // If the pointers point into different address spaces
      or if they point to<br>
        // values with different sizes, we can't do the transformation.<br>
        if (!IC.getDataLayout() ||<br>
            SrcTy->getAddressSpace() !=<br>
             
      cast<PointerType>(CI->getType())->getAddressSpace() ||<br>
            IC.getDataLayout()->getTypeSizeInBits(SrcPTy) !=<br>
            IC.getDataLayout()->getTypeSizeInBits(DestPTy))<br>
          return 0;<br>
    </blockquote>
    I think the address space check here is still required. It might be
    cleaner to bailout earlier on if the cast instruction is an address
    space cast instead of a bitcast. Is that what you had in mind?<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Richard Osborne | XMOS
<a class="moz-txt-link-freetext" href="http://www.xmos.com">http://www.xmos.com</a>
</pre>
  </body>
</html>