[PATCH] D68328: Fix occurrences that size and range of pointers are assumed to be the same.

Elena Demikhovsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 17 06:13:02 PST 2019


delena added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:5713
       KnownBits Known = computeKnownBits(U->getValue(), DL, 0, &AC, nullptr, &DT);
+      if (Known.getBitWidth() != BitWidth)
+        Known = Known.zextOrTrunc(BitWidth, true);
----------------
Your patch will work when Index type < Pointer type. So it's ok for us.
In general, I'd add a function to ScalarEvoultion bool truncatesEffectiveSCEVType(Type *, int *NumOfTruncatedBits) that returns true if SCEV effective type smaller than real type and use it here:

if (Known.getBitWidth() > BitWidth && truncatesEffectiveSCEVType(U->getValue()->getType())
  Known = Known.trunc(BitWidth);

And I still assume that new SCEV types scAddPtr and scPtrDiff will allow to remove these compensations.




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68328/new/

https://reviews.llvm.org/D68328





More information about the llvm-commits mailing list