[llvm-dev] Spurious peeling in simple loop unrolling

Florian Hahn via llvm-dev
2021-03-10T10:58:11Z

> On Mar 9, 2021, at 13:13, Thomas Preud'homme <thomasp at
graphcore.ai> wrote:
>
> On 08/03/2021 16:50, Florian Hahn wrote:
>>
>>
>>> On Mar 4, 2021, at 15:53, Thomas Preud'homme <thomasp at
graphcore.ai <mailto:thomasp at graphcore.ai>> wrote:
>>>> 2. Instcombine before peeling already simplifies the IR so that
both incoming values are bit casts of the same value. It probably would be
trivial to also have instcombine simplify pointer phis if the incoming values
striped by pointer casts are equal. (There might be some other reason why we are
not doing this at the moment though).
>>>
>>> As mentioned above, it's not as simple as bitcast of the same
pointer so this would not work here. One would have to go look at whether the
loads are equivalent which is a more involved check.
>>>
>>>
>>>
>>
>> That’s true, but I think instcombine already CSE’d the loads. So if we
simplify such phis, the unnecessary peeling should not happen
https://reviews.llvm.org/D98058 <https://reviews.llvm.org/D98058>
>
> I tried the patch (thanks) but that did not remove any of the PHI (the 2
loads are still there and thus the bitcast don't appear to have the same
source). I'll try tolook at InstCombine to see why loads are not CSE'd.
>
>


I’m not sure I follow here. For your example (spurious_loop_peeling.cpp), it
looks like there’s no peeling happening any more after the patch landed, at
least when building for ARM64: https://godbolt.org/z/q6d6Kn . Is there anything
else that’s going wrong?

Cheers,
Florian

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20210310/3269401e/attachment.html>