diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-03-15 11:24:07 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-03-15 11:59:25 +0000 |
commit | 9ba577eca2e339726bfaad4e615c6324a705b292 (patch) | |
tree | 796128a0692d094629efa05fb4e4dfb5c2ef595b /llvm/lib | |
parent | 61d314024dc447e49481cb8494bf7165f9ec1323 (diff) | |
download | llvm-9ba577eca2e339726bfaad4e615c6324a705b292.zip llvm-9ba577eca2e339726bfaad4e615c6324a705b292.tar.gz llvm-9ba577eca2e339726bfaad4e615c6324a705b292.tar.bz2 |
[X86][SSE] canonicalizeShuffleWithBinOps - handle target shuffles. NFCI.
Fold SHUFFLE(BINOP(SHUFFLE(X),SHUFFLE(Y))) -> BINOP(SHUFFLE'(X),SHUFFLE'(Y)) style patterns as well as the existing shuffles of constants.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index a2eb28f..5a21982 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -36814,7 +36814,7 @@ static SDValue combineCommutableSHUFP(SDValue N, MVT VT, const SDLoc &DL, return SDValue(); } -// Canonicalize SHUFFLE(BINOP(X,C)) -> BINOP(SHUFFLE(X),SHUFFLE(C)). +// Canonicalize SHUFFLE(BINOP(X,Y)) -> BINOP(SHUFFLE(X),SHUFFLE(Y)). static SDValue canonicalizeShuffleWithBinOps(SDValue N, SelectionDAG &DAG, const SDLoc &DL) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -36822,11 +36822,14 @@ static SDValue canonicalizeShuffleWithBinOps(SDValue N, SelectionDAG &DAG, auto IsMergeableWithShuffle = [](SDValue Op) { // AllZeros/AllOnes constants are freely shuffled and will peek through - // bitcasts. Other constant build vectors do not peek through bitcasts. + // bitcasts. Other constant build vectors do not peek through bitcasts. Only + // merge with target shuffles if it has one use so shuffle combining is + // likely to kick in. return ISD::isBuildVectorAllOnes(Op.getNode()) || ISD::isBuildVectorAllZeros(Op.getNode()) || ISD::isBuildVectorOfConstantSDNodes(Op.getNode()) || - ISD::isBuildVectorOfConstantFPSDNodes(Op.getNode()); + ISD::isBuildVectorOfConstantFPSDNodes(Op.getNode()) || + (isTargetShuffle(Op.getOpcode()) && Op->hasOneUse()); }; auto IsSafeToMoveShuffle = [ShuffleVT](SDValue Op, unsigned BinOp) { // Ensure we only shuffle whole vector src elements, unless its a logical |