[PATCH] D92745: [LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the counter is decrementing.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 7 00:58:39 PST 2020


craig.topper added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp:1484-1489
   for (BasicBlock::iterator Iter = LoopEntry->getFirstNonPHI()->getIterator(),
                             IterE = LoopEntry->end();
        Iter != IterE; Iter++) {
     Instruction *Inst = &*Iter;
     if (Inst->getOpcode() != Instruction::Add)
       continue;
----------------
lebedev.ri wrote:
> Preexisting problem, but this is //kinda// broken.
> If we have a second `add` in the loop,
> and it happens to be before the one we are looking for,
> we'll fail to detect the idiom.
> The detection should not involve linear scan over instructions.
All the fails are continues. So wouldn’t the second add also have to be a recurrence with 1/-1?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92745



More information about the llvm-commits mailing list