[llvm] [SCEV] Use context sensative reasoning in howFarToZero (PR #94525)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 08:32:54 PDT 2024


================
@@ -10485,16 +10485,19 @@ ScalarEvolution::ExitLimit ScalarEvolution::howFarToZero(const SCEV *V,
   const SCEV *Step = getSCEVAtScope(AddRec->getOperand(1), L->getParentLoop());
   const SCEVConstant *StepC = dyn_cast<SCEVConstant>(Step);
 
-  if (!isLoopInvariant(Step, L) || !isKnownNonZero(Step))
+  if (!isLoopInvariant(Step, L))
     return getCouldNotCompute();
 
+  // Specialize step for this loop so we get context sensative facts below.
----------------
nikic wrote:

```suggestion
  // Specialize step for this loop so we get context sensitive facts below.
```

https://github.com/llvm/llvm-project/pull/94525


More information about the llvm-commits mailing list