[PATCH] D92745: [LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the counter is decrementing.
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 00:39:57 PST 2020
lebedev.ri added a comment.
Seems to look ok in principle, but needs some negative tests too.
================
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;
----------------
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.
================
Comment at: llvm/test/Transforms/LoopIdiom/X86/ctlz.ll:531
+; Recognize CTLZ builtin pattern.
+; Here it will replace the loop -
+; assume builtin is always profitable.
----------------
Precommit this + use update script?
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