[PATCH] D116473: [VPlan] Don't consider VPWidenCanonicalIVRecipe phi-like.

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 1 14:25:02 PST 2022


Ayal added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8451
     // This is used instead of IV < TC because TC may wrap, unlike BTC.
     // Start by constructing the desired canonical IV in the header block.
     VPValue *IV = nullptr;
----------------
How about ironing this a bit, while we're here, e.g.:

```
    // Introduce the early-exit compare IV <= BTC to form header block mask.
    // This is used instead of IV < TC because TC may wrap, unlike BTC.
    // Start by constructing the desired canonical IV in the header block as its first non-phi instructions.
    assert(CM.foldTailByMasking() && "must fold the tail");
    VPBasicBlock *HeaderVPBB = Plan->getEntry()->getEntryBasicBlock();
    auto NewInsertionPoint = HeaderVPBB->getFirstNonPhi();

    VPValue *IV = nullptr;
    if (Legal->getPrimaryInduction())
      IV = Plan->getOrAddVPValue(Legal->getPrimaryInduction());
    else {
      auto *IVRecipe = new VPWidenCanonicalIVRecipe();
      HeaderVPBB->insert(IVRecipe, NewInsertionPoint);
      IV = IVRecipe;
    }

    assert(Builder.getInsertBlock() == HeaderVPBB && "..."); // if desired?
    VPBuilder::InsertPointGuard Guard(Builder);
    Builder.setInsertPoint(HeaderVPBB, NewInsertionPoint);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116473



More information about the llvm-commits mailing list