[PATCH] D69617: [LoopUnroll] countToEliminateCompares(): fix handling of [in]equality predicates (PR43840)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 08:24:52 PDT 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: fhahn, mkazantsev, efriedma.
lebedev.ri added a project: LLVM.
Herald added subscribers: zzheng, hiraditya.

I believe this bisects to https://reviews.llvm.org/D44983 (`[LoopUnroll] Only peel if a predicate becomes known in the loop body.`)

While that revision did contain tests that showed arguably-subpar peeling for
[in]equality predicates that [not] happen in the middle of the loop,
it also disabled peeling for the *first* loop iteration,
because latch would be canonicalized to [in]equality comparison..

That was intentional as per https://reviews.llvm.org/D44983#1059583.
I'm not 100% sure that i'm using correct checks here,
but this fix appears to be going in the right direction..

There also was this comment:

In D44983#1059583 <https://reviews.llvm.org/D44983#1059583>, @fhahn wrote:

> For ICMP_EQ and ICMP_NE without wrapping, I think we could peel of
>  an additional iteration and then the loop body could be simplified too.


I'm not really sure how that would look, if we look at `-loop-unroll -O3`
for those tests, said loops no longer have that condition anyway.
And if we do peel off one more iteration regardless, then we bloat
the code by performing one loop iteration outside of the loop,
without simplifying the loop.

Let me know if i'm missing some checks here..

Fixes PR43840 <https://bugs.llvm.org/show_bug.cgi?id=43840>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69617

Files:
  llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
  llvm/test/Transforms/LoopUnroll/peel-loop-conditions.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69617.227105.patch
Type: text/x-patch
Size: 13973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191030/fd831b94/attachment.bin>


More information about the llvm-commits mailing list