[llvm] ff471dc - [SCEV] Fix verification of SCEV multiples.
Joshua Cao via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 21:03:03 PDT 2023
Author: Joshua Cao
Date: 2023-05-31T21:00:22-07:00
New Revision: ff471dcf7669b1ad7903a44d0773bef4eb175eb9
URL: https://github.com/llvm/llvm-project/commit/ff471dcf7669b1ad7903a44d0773bef4eb175eb9
DIFF: https://github.com/llvm/llvm-project/commit/ff471dcf7669b1ad7903a44d0773bef4eb175eb9.diff
LOG: [SCEV] Fix verification of SCEV multiples.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 30691e902ba9..db8ac4fb3a62 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -14286,16 +14286,16 @@ void ScalarEvolution::verify() const {
}
}
- // Verify that ConstantMultipleCache computations are correct. It is possible
- // that a recomputed multiple has a higher multiple than the cached multiple
- // due to strengthened wrap flags. In this case, the cached multiple is a
- // conservative, but still correct if it divides the recomputed multiple. As
- // a special case, if if one multiple is zero, the other must also be zero.
+ // Verify that ConstantMultipleCache computations are correct. We check that
+ // cached multiples and recomputed multiples are multiples of each other to
+ // verify correctness. It is possible that a recomputed multiple is
diff erent
+ // from the cached multiple due to strengthened no wrap flags or changes in
+ // KnownBits computations.
for (auto [S, Multiple] : ConstantMultipleCache) {
- APInt RecomputedMultiple = SE2.getConstantMultipleImpl(S);
- if ((Multiple != RecomputedMultiple &&
- (Multiple == 0 || RecomputedMultiple == 0)) &&
- RecomputedMultiple.urem(Multiple) != 0) {
+ APInt RecomputedMultiple = SE2.getConstantMultiple(S);
+ if ((Multiple != 0 && RecomputedMultiple != 0 &&
+ Multiple.urem(RecomputedMultiple) != 0 &&
+ RecomputedMultiple.urem(Multiple) != 0)) {
dbgs() << "Incorrect cached computation in ConstantMultipleCache for "
<< *S << " : Computed " << RecomputedMultiple
<< " but cache contains " << Multiple << "!\n";
More information about the llvm-commits
mailing list