]> granicus.if.org Git - llvm/commitdiff
[BasicAA] Add type check and Value equality check around code added in r305481.
authorCraig Topper <craig.topper@intel.com>
Thu, 22 Jun 2017 19:04:14 +0000 (19:04 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 22 Jun 2017 19:04:14 +0000 (19:04 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306044 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicAliasAnalysis.cpp

index 5395762477f076c4fc9849f0c59734ebd722762f..b52a1d7b24d62fd9793220dd05333a4d5669911b 100644 (file)
@@ -1021,11 +1021,14 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
         // 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;
     }