This is an archive of the discontinued LLVM Phabricator instance.

[LV] Ignore runtime checks threshold when vectorization is forced
AcceptedPublic

Authored by nikolaypanchenko on Jan 20 2023, 2:53 PM.

Details

Summary

When number of needed runtime checks exceeds threshold, but user
requested vectorization, loop vectorizer simply doesn't generate them
which results to invalid vector code.
The patch simply forced generation of rt-checks when vectorization is
forced

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 2:53 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikolaypanchenko requested review of this revision.Jan 20 2023, 2:53 PM
fhahn added a comment.Jan 21 2023, 2:01 PM

Thanks for the patch! Add some suggestion on how to simplify the tests a bit. Also, could you pre-commit the simplified tests independent of the patch and then update the revision here to just show the difference caused by the patch?

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
1919

nit: period at end of sentence.

llvm/test/Transforms/LoopVectorize/memcheck_threashold_vec_forced.ll
6

Given that the test checks the full IR, it would probably be better to remove the check of debug output and run it unconditionally (remove REQUIRES: asserts).

63

the check shouldn't be needed.

67

can just pass %n as i64 and get rid of the zext.

71

can directly return here and maybe move the exit block to the end of the function.

77

can drop indvars. prefix to make value names more compact and readable.

Please file a bug if there isn't one already.

nikolaypanchenko marked 5 inline comments as done.

Addressed comments

llvm/test/Transforms/LoopVectorize/memcheck_threashold_vec_forced.ll
6

Mostly I added it to check that vec_not_forced is not vectorized due to the number of checks exceeded threshold. Agree that for the vec_forced it's not needed though, just tried to keep checks similar

fhahn accepted this revision.Jan 23 2023, 2:07 PM

LGTM thanks! Please reference the bug in the commit message.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
1919

nit: perhaps: unless the user...

This revision is now accepted and ready to land.Jan 23 2023, 2:07 PM