This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Fold CONCAT_VECTORS of EXTRACT_SUBVECTOR (or undef) to VECTOR_SHUFFLE.
ClosedPublic

Authored by RKSimon on Aug 18 2015, 3:54 PM.

Details

Summary

Check to see if this is a CONCAT_VECTORS of a bunch of EXTRACT_SUBVECTOR operations. If so, and if the EXTRACT_SUBVECTOR vector inputs come from at most two distinct vectors the same size as the result, attempt to turn this into a legal shuffle.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 32468.Aug 18 2015, 3:54 PM
RKSimon retitled this revision from to [DAGCombiner] Fold CONCAT_VECTORS of EXTRACT_SUBVECTOR (or undef) to VECTOR_SHUFFLE..
RKSimon updated this object.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
andreadb edited edge metadata.Aug 19 2015, 5:36 AM

Hi Simon,

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
103

This is the first place (at least on x86) where we check if VT is a legal type.
What about performing that check before calling 'combineConcatVectorOfExtracts' (at around line 12381)?
On x86, if VT is not legal, then we know in advance that the concat_vectors will not be folded. On other targets that don't check for the legality of VT in 'isShuffleMaskLegal', the folding would be premature. What do you think?

105

remove extra semicolon.

RKSimon updated this revision to Diff 32541.Aug 19 2015, 6:20 AM
RKSimon edited edge metadata.

Thanks Andrea, we've used the (Level < AfterLegalizeVectorOps && TLI.isTypeLegal(VT)) pattern in a lot of other shuffle code so don't have a problem adding it here.

andreadb accepted this revision.Aug 19 2015, 8:09 AM
andreadb edited edge metadata.

LGTM

Thanks!

This revision is now accepted and ready to land.Aug 19 2015, 8:09 AM
This revision was automatically updated to reflect the committed changes.