[llvm] r306044 - [BasicAA] Add type check and Value equality check around code added in r305481.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 12:04:14 PDT 2017


Author: ctopper
Date: Thu Jun 22 14:04:14 2017
New Revision: 306044

URL: http://llvm.org/viewvc/llvm-project?rev=306044&view=rev
Log:
[BasicAA] Add type check and Value equality check around code added in r305481.

This matches the checks done at the beginning of isKnownNonEqual that this code is partially emulating.

Without this we can get assertion failures due to the bit widths of the KnownBits not matching.

Modified:
    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=306044&r1=306043&r2=306044&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Jun 22 14:04:14 2017
@@ -1021,11 +1021,14 @@ static AliasResult aliasSameBasePointerG
         // asking about values from different loop iterations. See PR32314.
         // TODO: We may be able to change the check so we only do this when
         // we definitely looked through a PHINode.
-        KnownBits Known1 = computeKnownBits(GEP1LastIdx, DL);
-        KnownBits Known2 = computeKnownBits(GEP2LastIdx, DL);
-        if (Known1.Zero.intersects(Known2.One) ||
-            Known1.One.intersects(Known2.Zero))
-          return NoAlias;
+        if (GEP1LastIdx != GEP2LastIdx &&
+            GEP1LastIdx->getType() == GEP2LastIdx->getType()) {
+          KnownBits Known1 = computeKnownBits(GEP1LastIdx, DL);
+          KnownBits Known2 = computeKnownBits(GEP2LastIdx, DL);
+          if (Known1.Zero.intersects(Known2.One) ||
+              Known1.One.intersects(Known2.Zero))
+            return NoAlias;
+        }
       } else if (isKnownNonEqual(GEP1LastIdx, GEP2LastIdx, DL))
         return NoAlias;
     }




More information about the llvm-commits mailing list