[PATCH] D137758: [HardwareLoops] remove loops which has undef count
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 18:57:32 PST 2022
shchenz added a comment.
In D137758#3918978 <https://reviews.llvm.org/D137758#3918978>, @nikic wrote:
> Can you please explain what the motivation for this change is?
This is from https://reviews.llvm.org/D135847#inline-1327746, in that patch, we found the loop being changed "invalidly" and then we found this is caused by `undef` loop count, so the "invalid" change is also OK.
And furthermore, we should be able to eliminate the `undef` count loop. This is what the LLVM opt component does, so we want to make llc align with opt.
================
Comment at: llvm/lib/CodeGen/HardwareLoops.cpp:447
+ // dedicated exit block, so we just delete these loops.
+ if (isa<UndefValue>(Count)) {
+ LLVM_DEBUG(dbgs() << " - Bailing, loop count is undef\n");
----------------
fhahn wrote:
> I doubt this is enough. I think you would at least have to ensure that the branch on undef is executed unconditionally in the loop. Also, shouldn't those dead loops be cleaned up earlier?
> I think you would at least have to ensure that the branch on undef is executed unconditionally in the loop.
For hardware loops, the exiting block which contains the compare with loop count will be executed in each loop iteration.
> Also, shouldn't those dead loops be cleaned up earlier?
OPT has the pass that can clean up this kind of loop. But in LLC pipeline, there is no such pass.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137758/new/
https://reviews.llvm.org/D137758
More information about the llvm-commits
mailing list