This is an archive of the discontinued LLVM Phabricator instance.

[VectorCombine] Attempt to fold select shuffles from reductions
ClosedPublic

Authored by dmgreen on May 6 2022, 3:08 AM.

Details

Summary

Given a commutative reduction leading from a shuffle, the order of the lanes on the shuffle are not important for the result. This means we can reorder the shuffle to something simpler, which it tries shuffling the first vector lanes first. This was D123494.

The new shuffle may not be profitable though, and if it is not we can try the folding of select shuffles from D123911. This, with some adjustment as the output lane ordering is now unimportant, can allow the final shuffle to simplify given the inputs to the patterns from D123911. Where as each transformation on their own are not profitable, to combination is.

We can only support a single shuffle when called from reductions, but we are able to sort the ReconstructMask, potentially allowing it to simplify to an identity or concat mask.

Diff Detail

Event Timeline

dmgreen created this revision.May 6 2022, 3:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2022, 3:08 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
dmgreen requested review of this revision.May 6 2022, 3:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2022, 3:08 AM
samtebbs accepted this revision.May 6 2022, 7:53 AM

Looks sensible to me, thanks

This revision is now accepted and ready to land.May 6 2022, 7:53 AM
This revision was landed with ongoing or failed builds.May 8 2022, 2:33 AM
This revision was automatically updated to reflect the committed changes.