This is an archive of the discontinued LLVM Phabricator instance.

[LV] Stability fix for outerloop vectorization
Needs ReviewPublic

Authored by nikolaypanchenko on May 16 2023, 11:36 AM.

Details

Reviewers
fhahn
ABataev
Summary

HCFG builder doesn't correctly handle cases when non-outermost loop is
requested to be vectorized

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2023, 11:36 AM
nikolaypanchenko requested review of this revision.May 16 2023, 11:36 AM
fhahn added inline comments.Aug 30 2023, 9:11 AM
llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp
122

I am not sure this check is sufficient, e.g. if BB is the header of an another loop with the same nesting level as TheLoop. Not sure if that's possible at the moment as a preheader might be required in all cases, still would be good to add a test case.

IIUC the condition we need to check is that CurrentLoop is either TheLoop or a sub loop of it; should be sufficient to check if TheLoop->contains(CurrentLoop). I think this only checks one level, but all loops we currently support should be an inner loop with its outer loop. Could also have an assertion to ensure that (e.g. walk up through CurrentLoop's parents and check that not more than 1 step is needed to reach TheLoop.

llvm/test/Transforms/LoopVectorize/outer_loop_test3.ll
3

-pass-remarks=loop-vectorize not needed?

18

would be good to have a more descriptive name & a comment with a brief description of what this tests. Test name could also include more info.

97

should not be needed

102

Could you rename the labels & value names to be more descriptive (and shorter)? e.g. something like loop.1.header, loop.1.latch, iv.1 and so on.

107

should not be needed.

fhahn added a comment.Sep 27 2023, 5:12 AM

Reverse ping. This patch should unblock adding first end-to-end testing for outer loop vectorization to the llvm-test-suite (https://github.com/llvm/llvm-test-suite/pull/20).

The VPlan construction logic changed quite since the patch was posted and I think the patch would need a rebase.

nikolaypanchenko added a comment.EditedSep 27 2023, 9:20 AM

Reverse ping. This patch should unblock adding first end-to-end testing for outer loop vectorization to the llvm-test-suite (https://github.com/llvm/llvm-test-suite/pull/20).

The VPlan construction logic changed quite since the patch was posted and I think the patch would need a rebase.

Thanks for reminder. I drowned in other work and forgot about it.
Will move it to github and address your comments there.

Reverse ping. This patch should unblock adding first end-to-end testing for outer loop vectorization to the llvm-test-suite (https://github.com/llvm/llvm-test-suite/pull/20).

The VPlan construction logic changed quite since the patch was posted and I think the patch would need a rebase.

Thanks for reminder. I drowned in other work and forgot about it.
Will move it to github and address your comments there.

Excellent, thank you very much!