[PATCH] D101290: [LV] Try to sink and hoist inside candidate loops for vectorization.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 28 09:23:05 PDT 2021


fhahn added a comment.

In D101290#2720661 <https://reviews.llvm.org/D101290#2720661>, @nikic wrote:

> I find it pretty odd that LoopVectorize would have this kind of side effect on code that's not vectorized. I don't think that's really the same as construction of LoopSimplify/LCSSA form, which is pretty much par the course for any loop pass. D84108 <https://reviews.llvm.org/D84108> mentions that:
>
>> I'm proposing to harmonize this, and disable common code hoisting until late
>> in pipeline. Definition of late may vary, currently i've picked the same one
>> as for code sinking, but i suppose we could enable it as soon as right after
>> loop rotation happens.
>
> I think that doing that (enabling hoisting in some post-LoopRotate SimplifyCFG run) would be cleaner than having it happen as a side-effect of LoopVectorize.

That's a fair point. Originally I did not adjust the SimplifyCFG runs, because we do a run of LoopRotate just before LoopVectorize in the legacy pass manager and the sinking/hoisting before may pessimize LoopRotate there. But it may not be a big issue (@lebedev.ri WDYT?), because sinking/hoisting before the second LoopRotate run should outweigh the risks of not rotating.

In general it is a bit unfortunate that LV is so sensitive to slight changes in the IR and very dependent on the specific position in the pipeline. As such, making it a bit more independent is desirable goal in general. In the future, we should be able to do the hoisting/sinking in VPlan, but that's still some way off. Unfortunately we cannot really perform the hoisting on loop that we can vectorize, because it would mess up runtime check SCEVs and a bunch of other things. Doing it in LV should disturb other passes less, but sinking/hoisting earlier is probably beneficial for a bunch of other passes as well.

I put up D101468 <https://reviews.llvm.org/D101468> as an alternative, but should fix that particular vectorization issues when using O2 <https://reviews.llvm.org/owners/package/2/>/O3 <https://reviews.llvm.org/owners/package/3/>.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101290



More information about the llvm-commits mailing list