[PATCH] D76838: [LV][LoopInfo] Transform counting-down loops to counting-up loop

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 10:19:15 PDT 2020


Meinersbur added inline comments.


================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:220
+//
+PHINode *Loop::reverseInductionVariable(ScalarEvolution &SE) {
+  BasicBlock *Preheader = getLoopPreheader();
----------------
 `Loop` is part of the `LLVMAnalysis` library. Transformations should be in the `LLVMTransform` library.

Also, it is untypical for the analysis results to have methods for modification as well. These are typically found in the LLVMTransform library such as `LoopUtils.cpp`


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:1192
+  // epilogue loop.
+  if (PHINode *IndVar = TheLoop->reverseInductionVariable(*PSE.getSE())) {
+    PrimaryInduction = IndVar;
----------------
`LoopVectorizationLegality::canVectorize` is not really a place for changing the IR.

It's also a speculative transformation: The IR will have changed even if the loop at the end will not be vectorized (e.g. because it's not profitable).


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

https://reviews.llvm.org/D76838





More information about the llvm-commits mailing list