<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 14, 2009, at 6:52 AM, Török Edwin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 2009-10-14 09:41, Evan Cheng wrote:<br><font class="Apple-style-span" color="#006312"><br></font>Hi Evan,<br><br>This gives MayAlias for a[4] and a[5], right? I think you shouldn't exit<br>for a MayAlias return, only for a NoAlias result:<br>you should check whether the [index1, index1+size1), and [index2,<br>index2+size2)  ranges overlap, which you seem to be doing later.<br></div></blockquote><div><br></div>No. a[4] and a[5] case is caught earlier in if (isGEP(V1) && isGEP(V2)) { .. } Their bases MustAlias.</div><div><br></div><div>Evan</div><div><br><blockquote type="cite"><div><br><br><blockquote type="cite">+    // If V2 is known not to alias GEP base pointer, then the two values<br></blockquote><blockquote type="cite">+    // cannot alias per GEP semantics: "A pointer value formed from a<br></blockquote><blockquote type="cite">+    // getelementptr instruction is associated with the addresses associated<br></blockquote><blockquote type="cite">+    // with the first operand of the getelementptr".<br></blockquote><blockquote type="cite">+    return R;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+  // If there is at least one non-zero constant index, we know they cannot<br></blockquote><blockquote type="cite">+  // alias.<br></blockquote><blockquote type="cite">+  bool ConstantFound = false;<br></blockquote><blockquote type="cite">+  bool AllZerosFound = true;<br></blockquote><blockquote type="cite">+  for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i)<br></blockquote><blockquote type="cite">+    if (const Constant *C = dyn_cast<Constant>(GEPOperands[i])) {<br></blockquote><blockquote type="cite">+      if (!C->isNullValue()) {<br></blockquote><blockquote type="cite">+        ConstantFound = true;<br></blockquote><blockquote type="cite">         AllZerosFound = false;<br></blockquote><blockquote type="cite">+        break;<br></blockquote><blockquote type="cite">       }<br></blockquote><blockquote type="cite">+    } else {<br></blockquote><blockquote type="cite">+      AllZerosFound = false;<br></blockquote><blockquote type="cite">+    }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-    // If we have getelementptr <ptr>, 0, 0, 0, 0, ... and V2 must aliases<br></blockquote><blockquote type="cite">-    // the ptr, the end result is a must alias also.<br></blockquote><blockquote type="cite">-    if (AllZerosFound)<br></blockquote><blockquote type="cite">-      return MustAlias;<br></blockquote><blockquote type="cite">+  // If we have getelementptr <ptr>, 0, 0, 0, 0, ... and V2 must aliases<br></blockquote><blockquote type="cite">+  // the ptr, the end result is a must alias also.<br></blockquote><blockquote type="cite">+  if (AllZerosFound)<br></blockquote><blockquote type="cite">+    return MustAlias;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-    if (ConstantFound) {<br></blockquote><blockquote type="cite">-      if (V2Size <= 1 && V1Size <= 1)  // Just pointer check?<br></blockquote><blockquote type="cite">-        return NoAlias;<br></blockquote><blockquote type="cite">+  if (ConstantFound) {<br></blockquote><blockquote type="cite">+    if (V2Size <= 1 && V1Size <= 1)  // Just pointer check?<br></blockquote><blockquote type="cite">+      return NoAlias;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-      // Otherwise we have to check to see that the distance is more than<br></blockquote><blockquote type="cite">-      // the size of the argument... build an index vector that is equal to<br></blockquote><blockquote type="cite">-      // the arguments provided, except substitute 0's for any variable<br></blockquote><blockquote type="cite">-      // indexes we find...<br></blockquote><blockquote type="cite">-      if (TD &&<br></blockquote><blockquote type="cite">-          cast<PointerType>(BasePtr->getType())->getElementType()->isSized()) {<br></blockquote><blockquote type="cite">-        for (unsigned i = 0; i != GEPOperands.size(); ++i)<br></blockquote><blockquote type="cite">-          if (!isa<ConstantInt>(GEPOperands[i]))<br></blockquote><blockquote type="cite">-            GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType());<br></blockquote><blockquote type="cite">-        int64_t Offset =<br></blockquote><blockquote type="cite">-          TD->getIndexedOffset(BasePtr->getType(),<br></blockquote><blockquote type="cite">-                               &GEPOperands[0],<br></blockquote><blockquote type="cite">-                               GEPOperands.size());<br></blockquote><blockquote type="cite">+    // Otherwise we have to check to see that the distance is more than<br></blockquote><blockquote type="cite">+    // the size of the argument... build an index vector that is equal to<br></blockquote><blockquote type="cite">+    // the arguments provided, except substitute 0's for any variable<br></blockquote><blockquote type="cite">+    // indexes we find...<br></blockquote><blockquote type="cite"><br></blockquote><br>However I don't see how this code is reached if the AA returns MayAlias<br>for a[4] and a[5], as the manual states:<br>The MayAlias response is used whenever the two pointers might refer to<br>the same object. If the two memory objects overlap, but do not start at<br>the same location, return MayAlias.<br><br>Best regards,<br>--Edwin<br></div></blockquote></div><br></body></html>