This is an archive of the discontinued LLVM Phabricator instance.

[X86] In lowerVectorShuffle, instead of creating a new node to canonicalize the shuffle mask by commuting, just commute the mask and swap V1/V2.
ClosedPublic

Authored by craig.topper on Jul 22 2019, 10:35 PM.

Details

Summary

LegalizeDAG tries to legal the DAG by legalizing nodes before
their operands.

If we create a new node, we end up legalizing it after its operands.
This prevents some of the optimizations that can be done when the
operand is a build_vector since the build_vector will have been
legalized to something else.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 22 2019, 10:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2019, 10:35 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper marked an inline comment as done.Jul 22 2019, 10:55 PM
craig.topper added inline comments.
llvm/test/CodeGen/X86/vector-shuffle-128-v2.ll
721 ↗(On Diff #211250)

Not sure if this should be considered a regression or not. The types are integers here so we're really matching an integer unpckh during shuffle lowering. We don't have an equivalent of movsd in the integer domain. Only later does the execution domain fixing pass move it to FP.

RKSimon accepted this revision.Jul 23 2019, 6:38 AM

LGTM - cheers

llvm/test/CodeGen/X86/vector-shuffle-128-v2.ll
721 ↗(On Diff #211250)

Annoying but not terrible - shuffle combining should probably catch this in matchBinaryShuffle for cases where one of the mask elements is zero.

This revision is now accepted and ready to land.Jul 23 2019, 6:38 AM
This revision was automatically updated to reflect the committed changes.