[llvm] [DA] Set Distance to zero when Direction is EQ (PR #147966)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 10 07:17:26 PDT 2025
================
@@ -3991,6 +4003,23 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
if (CompleteLoops[II])
Result.DV[II - 1].Scalar = false;
+ // Set the distance to zero if the direction is EQ.
+ // TODO: Ideally, the distance should be set to 0 immediately simultaneously
+ // with the corresponding direction being set to EQ.
+ for (unsigned II = 1; II <= Result.getLevels(); ++II) {
+ if (Result.getDirection(II) == Dependence::DVEntry::EQ)
+ Result.DV[II - 1].Distance = SE->getZero(SrcSCEV->getType());
+
+ LLVM_DEBUG({
+ // Check that the converse (i.e., if the distance is zero, then the
+ // direction is EQ) holds.
+ const SCEV *Distance = Result.getDistance(II);
+ if (Distance && Distance->isZero())
+ assert(Result.getDirection(II) == Dependence::DVEntry::EQ &&
+ "Distance is zero, but direction is not EQ");
+ });
----------------
Meinersbur wrote:
```suggestion
#ifndef NDEBUG
// Check that the converse (i.e., if the distance is zero, then the
// direction is EQ) holds.
const SCEV *Distance = Result.getDistance(II);
if (Distance && Distance->isZero())
assert(Result.getDirection(II) == Dependence::DVEntry::EQ &&
"Distance is zero, but direction is not EQ");
#endif
```
For multi-line checks, prefer `#ifndef NDEBUG`. LLVM_DEBUG confuses tooling such as clang-format, debuggers, clang-tidy, code completion, refactoring
https://github.com/llvm/llvm-project/pull/147966
More information about the llvm-commits
mailing list