This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Update getNode asserts for EXTRACT/INSERT_SUBVECTOR.
ClosedPublic

Authored by paulwalker-arm on May 28 2020, 4:03 AM.

Details

Summary

The description of EXTACT_SUBVECTOR and INSERT_SUBVECTOR has been
changed to accommodate scalable vectors (see ISDOpcodes.h). This
patch updates the asserts used to verify these requirements when
using SelectionDAG's getNode interface.

This patch introduces the MVT function getVectorMinNumElements
that can be used against fixed-length and scalable vectors when
only the known minimum vector length is required.

Diff Detail

Event Timeline

paulwalker-arm created this revision.May 28 2020, 4:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 28 2020, 4:03 AM

I'm waiting on a FileCheck patch to land before the fixed width code generation for SVE patches can move on so I've broken some assert fixes out of D80385 to help protect future work. There's no new tests as the core logic is already tested and D80385 is required to exercise the corner cases.

david-arm added inline comments.May 28 2020, 5:06 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
5471

This suggests we permit fixed width vectors of arbitrary length being extracted as subvectors from a scalable vector. That's ok, but presumably we'll need to support that in the backend too with appropriate undefs being used to fill in the parts that exceed the bounds of the scalable vector.

5679

Same as above, this suggets we permit arbitrarily large fixed width vectors being inserted into a scalable vector.

paulwalker-arm marked an inline comment as done.May 28 2020, 5:33 AM
paulwalker-arm added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
5471

Yes and no. We do permit the extraction of an arbitrary length fixed length vector from a scalable vector but the requirement that the extracted vector must be smaller than the source vector stands. As does the requirement for there to be no overflow. It's just that we cannot protect against those invalid use cases with a compiler time assert.

sdesmalen added inline comments.May 28 2020, 6:05 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
5471

In D79806 we've defined insert/extract_subvector such that the result vector can be considered undefined if it is inserting/extracting beyond the valid runtime vector length.

/// Elements IDX through (IDX + num_elements(T) - 1) must be valid VECTOR1
/// indices. If this condition cannot be determined statically but is false at
/// runtime, then the result vector is undefined.
efriedma accepted this revision.May 28 2020, 12:35 PM
efriedma added a subscriber: efriedma.

LGTM

This revision is now accepted and ready to land.May 28 2020, 12:35 PM
This revision was automatically updated to reflect the committed changes.