This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG][VP] Provide expansion for VP_MERGE
ClosedPublic

Authored by frasercrmck on Jan 24 2022, 10:25 AM.

Details

Summary

This patch adds support for expanding VP_MERGE through a sequence of
vector operations producing a full-length mask setting up the elements
past EVL/pivot to be false, combining this with the original mask, and
culminating in a full-length vector select.

This expansion should work for any data type, though the only use for
RVV is for boolean vectors, which themselves rely on an expansion for
the VSELECT.

Diff Detail

Event Timeline

frasercrmck created this revision.Jan 24 2022, 10:25 AM
frasercrmck requested review of this revision.Jan 24 2022, 10:25 AM

I haven't done much work in expansions so don't know exactly how/when best to check to unroll. For example, I didn't want to check whether VSELECT was marked as Expand because we rely on that expansion. But if the VSELECT were to unroll then arguably VP_MERGE should unroll.. So should the expansion of VP_MERGE duplicate logic that should be internal to ExpandVSELECT?

craig.topper added inline comments.Jan 25 2022, 11:56 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
1269

This just going to crash if scalable vectors hit the UnrollVectorOp?

I haven't done much work in expansions so don't know exactly how/when best to check to unroll. For example, I didn't want to check whether VSELECT was marked as Expand because we rely on that expansion. But if the VSELECT were to unroll then arguably VP_MERGE should unroll.. So should the expansion of VP_MERGE duplicate logic that should be internal to ExpandVSELECT?

I think I'm ok not duplicating it.

This revision is now accepted and ready to land.Jan 26 2022, 1:19 PM
This revision was landed with ongoing or failed builds.Jan 27 2022, 1:11 AM
This revision was automatically updated to reflect the committed changes.