[PATCH] D118167: [VPlan] Record whether scalar IVs are need in induction recipe. (NFC)

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 09:12:20 PST 2022


fhahn marked 2 inline comments as done.
fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2588
   // true if the induction variable itself is not widened, or if it has at
   // least one user in the loop that is not widened.
+  if (Def->needsVectorIV() && !Def->needsScalarIV()) {
----------------
Ayal wrote:
> While we're here, comment above is out of sync with code below.
Updated, thanks!


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8606
+    return new VPWidenIntOrFpInductionRecipe(
+        Phi, Start, II, I, NeedsScalarIV, !NeedsScalarIV || !NeedsScalarIVOnly);
   }
----------------
Ayal wrote:
> `!NeedsScalarIV || !NeedsScalarIVOnly` - suffice to have only `!NeedsScalarIVOnly` to feed `NeedsVectorIV` ?
> 
> Refactor the code that constructs a VPWidenIntOrFpInductionRecipe to be used by both tryToOptimizeInduction[PHI,Truncate]?
Good point, thanks! Looks like `!NeedsScalarIVOnly` is indeed sufficient. Updated and also moved to common `createInductionRecipe` helper!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118167



More information about the llvm-commits mailing list