This is an archive of the discontinued LLVM Phabricator instance.

Separate the check for blend shuffle_vector masks
ClosedPublic

Authored by filcab on May 29 2014, 9:13 PM.

Details

Summary

Separate the check for blend shuffle_vector masks into isBlendMask.
This function will also be used to check if a vector shuffle is legal. No
change in functionality was intended, but we ended up improving codegen on
two tests, which were being (more) optimized only if the resulting shuffle
was legal.

Diff Detail

Repository
rL LLVM

Event Timeline

filcab updated this revision to Diff 9943.May 29 2014, 9:13 PM
filcab retitled this revision from to Separate the check for blend shuffle_vector masks.
filcab updated this object.
filcab edited the test plan for this revision. (Show Details)
filcab added reviewers: nadav, delena, andreadb.
filcab added a subscriber: Unknown Object (MLST).
andreadb edited edge metadata.May 30 2014, 10:11 AM

Hi Filipe,

By adding the call 'isBlendMask' to 'X86TargetLowering::isShuffleMaskLegal' you actually made a functional change.
With you change, the DAGCombiner now is able to fold more vector OR dag nodes according to rules:

fold (or (shuf A, V_0, MA), (shuf B, V_0, MB)) -> (shuf A, B, Mask1)
fold (or (shuf A, V_0, MA), (shuf B, V_0, MB)) -> (shuf A, B, Mask1).

I think that the behavior change in the DAGCombiner is good (as you said, we optimize more cases; that explains why you had to "fix" test 'combine-or.ll').

I can see other uses of method 'isShuffleMaskLegal' in LegalizeDAG.cpp and LegalizeVectorOps.cpp.
For example, in LegalizeDAG.cpp, method SelectionDAGLegalize::ExpandBUILD_VECTOR calls 'isShuffleMaskLegal' to see if it is possible to expand build_vector dag nodes into legal shuffles.

The other place where we call 'isShuffleMaskLegal' is LegalizeVectorOps.cpp.
More specifically, method ExpandBSWAP uses it to check if we can generate a legal byte wise shuffle to implement a BSWAP.

That said, I cannot see how your change might have negatively affected those methods.

For what is worth, your change looks good to me (it definitely makes sense for the DAGCombiner).

andreadb accepted this revision.May 30 2014, 10:11 AM
andreadb edited edge metadata.
This revision is now accepted and ready to land.May 30 2014, 10:11 AM
filcab closed this revision.May 30 2014, 2:39 PM
filcab updated this revision to Diff 9965.

Closed by commit rL209923 (authored by @filcab).