This is an archive of the discontinued LLVM Phabricator instance.

LoadStoreVectorizer: Match nested adds to prove vectorization is safe
ClosedPublic

Authored by volkan on May 12 2020, 3:36 PM.

Details

Summary

If both OpA and OpB is an add with NSW/NUW and with the same LHS operand,
we can guarantee that the transformation is safe if we can prove that OpA
won't overflow when IdxDiff added to the RHS of OpA.

Diff Detail

Event Timeline

volkan created this revision.May 12 2020, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2020, 3:36 PM
arsenm added inline comments.May 12 2020, 4:06 PM
llvm/test/Transforms/LoadStoreVectorizer/X86/vectorize-i8-nested-add.ll
11

Can you reduce this any further?

Also could use some negative cases where the flags don't match up

volkan marked an inline comment as done.May 12 2020, 5:17 PM
volkan added inline comments.
llvm/test/Transforms/LoadStoreVectorizer/X86/vectorize-i8-nested-add.ll
11

Do you mean reducing the number of loads? I added 4 loads to make sure we test different patterns.

volkan updated this revision to Diff 263764.May 13 2020, 10:00 AM
  • Reduced the test and the number of check lines.
  • Added a test with nuw.
  • Added a negative test.
volkan updated this revision to Diff 263775.EditedMay 13 2020, 10:34 AM
  • Removed the irrelevant changes that I accidentally added.
arsenm accepted this revision.May 13 2020, 10:48 AM

LGTM although overflow flags scare me

This revision is now accepted and ready to land.May 13 2020, 10:48 AM
volkan closed this revision.May 18 2020, 12:14 PM

Committed in 63081dc6f64.