This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Extend WidenVecOp_INSERT_SUBVECTOR to cover more cases.
ClosedPublic

Authored by paulwalker-arm on Jun 10 2022, 9:19 AM.

Details

Summary

WidenVecOp_INSERT_SUBVECTOR only supported cases where widening
effectively converts the insert into a copy. However, when the
widened subvector is no bigger than the vector being inserted into
and we can be sure there's no loss of data, we can simply emit
another INSERT_SUBVECTOR.

Fixes: #54982

Diff Detail

Event Timeline

paulwalker-arm created this revision.Jun 10 2022, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 9:19 AM
paulwalker-arm requested review of this revision.Jun 10 2022, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 9:19 AM
paulwalker-arm added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
5795–5796

This code looks bogus as a change of InVec implies a change of result type and that is something WidenVecOp_*** should not do. Beforehand I did add an assert(false) to verify no existing test exercises the codepath.

sdesmalen accepted this revision.Jun 13 2022, 10:39 AM
sdesmalen added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
5801–5802

Given that no other tests have changed, I assume that getNode returns SubVec if SubVec.getValueType() == InVec.getValueType() ?

This revision is now accepted and ready to land.Jun 13 2022, 10:39 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
5801–5802

Yes, after the asserts to ensure the insert is valid it starts with

// Trivial insertion.
if (VT == N2VT)
  return N2;