<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 03/15/2015 10:43 PM, Junjie Gu
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAFF36jLvj2MUJdMezJfmAn_Kr5d8Z=6-pWR6=SgF3j3i4AmErg@mail.gmail.com"
      type="cite">
      <div class="moz-text-html" lang="x-unicode">
        <meta http-equiv="Content-Type" content="text/html;
          charset=windows-1252">
        <div dir="ltr">
          <div>
            <div>Given a pointer,  does any addrspacecast affect the
              pointer's<br>
              dereferenceablity ?  For example,<br>
                  %pm = addrspaacecast float addrspacecast(n)* %pn to
              float addrspacecast(m)*<br>
                  %r  = load float addrspace(m)* %pm<br>
              In another word. the question is whether the following is
              true ?<br>
                  isDereferenceablePointer(pn) ==
              isDereferenceablePointer(pm)<br>
              <br>
                [Note that the function is defined as<br>
                 Value.cpp:isDereferenceaablePointer(const Value*, ...)
              ]<br>
              <br>
              <br>
              The reason I am asking this is that the current LLVM
              thinks the answer is yes<br>
              (they are the same).  But for the following case, it will
              make non-speculative<br>
              load to be moved out of its guard.  For example (assume
              that isDereferenceablePointer(p)<br>
              is true),<br>
              <br>
              The following code:<br>
              <br>
                   %pm = addrspaacecast float* %p to float
              addrspacecast(m)*<br>
                   if (p is in addrspace(m))<br>
                      // BB_then<br>
                      %r0 = load float,  float addrspace(m)* %pm;<br>
                   else  // p is in default addrspace<br>
                      // BB_else<br>
                      %r1 = load float,  float* p;<br>
                   %r = phi float [r0, BB_then], [r1, BB_else]<br>
              <br>
              will be transformed to<br>
              <br>
                   %pm = addrspaacecast float* %p to float
              addrspacecast(m)*<br>
                   %r0 = load float addrspace(m)* %pm;<br>
                   %r1 = load float* p;<br>
                   %r = select i1 (p is in adrspace(m)) float %r0, float
              %r1<br>
              <br>
              which is wrong as "%r0 = load float addrspace(m)* %pm"
              would be illegal<br>
              if (p is in addrspace(m)) is false.<br>
              <br>
              If we agree that the answer to the above question is no,
              then fix<br>
              is simple (fix diff is attached). I also have a small test
              to show<br>
              the problem,  simplifyCFG actually does the above
              transformation<br>
              (to reproduce, use "opt -simplifycfg -S test3.ll -o
              tt.ll).<br>
              <br>
            </div>
            <div>Any suggestions/comments ?<br>
            </div>
            <div><br>
              <br>
            </div>
            thanks<br>
          </div>
          Junjie<br>
        </div>
      </div>
    </blockquote>
    <br>
    <br>
    I think the pointer should still be dereferencable once casted, but
    since the testcase can be predicated on the address space your
    testcase looks broken. Have you tried making addrspacecast not
    isSafeToSpeculativelyExecute?<br>
    <br>
    <br>
    <blockquote
cite="mid:CAFF36jLvj2MUJdMezJfmAn_Kr5d8Z=6-pWR6=SgF3j3i4AmErg@mail.gmail.com"
      type="cite">
      <div class="moz-text-html" lang="x-unicode">
        <div dir="ltr">
          <div>
            <div><br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"><legend
          class="mimeAttachmentHeaderName">fix.diff</legend></fieldset>
      <br>
      <div class="moz-text-plain" wrap="true" graphical-quote="true"
        style="font-family: -moz-fixed; font-size: 12px;"
        lang="x-western">
        <pre wrap="">Index: Value.cpp
===================================================================
--- Value.cpp   (revision 232165)
+++ Value.cpp   (working copy)
@@ -574,8 +574,8 @@
       return isDereferenceablePointer(RelocateInst.derivedPtr(), DL, Visited);
     }
 
-  if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
-    return isDereferenceablePointer(ASC->getOperand(0), DL, Visited);
+//  if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+//    return isDereferenceablePointer(ASC->getOperand(0), DL, Visited);
 
   // If we don't know, assume the worst.
   return false;

</pre>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <div class="moz-text-plain" wrap="true" graphical-quote="true"
        style="font-family: -moz-fixed; font-size: 12px;"
        lang="x-western">
        <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
      </div>
    </blockquote>
    <br>
  </body>
</html>