Skip to content

Commit

Permalink
[X86][AVX] combineConcatVectorOps - use getBROADCAST_LOAD helper for …
Browse files Browse the repository at this point in the history
…splat of normal vector loads. NFCI.

Reapplied from rG1cfecf4fc427 with fix for PR51226 - ensure the load is a normal (non-ext) load.
  • Loading branch information
RKSimon committed Nov 2, 2021
1 parent dd5ce50 commit 53900a1
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Expand Up @@ -51665,9 +51665,11 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
if (Op0.getOpcode() == X86ISD::VBROADCAST)
return DAG.getNode(Op0.getOpcode(), DL, VT, Op0.getOperand(0));

// If this scalar/subvector broadcast_load is inserted into both halves, use
// a larger broadcast_load. Update other uses to use an extracted subvector.
if (Op0.getOpcode() == X86ISD::VBROADCAST_LOAD ||
// If this simple subvector or scalar/subvector broadcast_load is inserted
// into both halves, use a larger broadcast_load. Update other uses to use
// an extracted subvector.
if (ISD::isNormalLoad(Op0.getNode()) ||
Op0.getOpcode() == X86ISD::VBROADCAST_LOAD ||
Op0.getOpcode() == X86ISD::SUBV_BROADCAST_LOAD) {
auto *Mem = cast<MemSDNode>(Op0);
unsigned Opc = Op0.getOpcode() == X86ISD::VBROADCAST_LOAD
Expand All @@ -51682,24 +51684,6 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
}
}

// If this is a simple subvector load repeated across multiple lanes, then
// broadcast the load. Update other uses to use an extracted subvector.
if (auto *Ld = dyn_cast<LoadSDNode>(Op0)) {
if (Ld->isSimple() && !Ld->isNonTemporal() &&
Ld->getExtensionType() == ISD::NON_EXTLOAD) {
SDVTList Tys = DAG.getVTList(VT, MVT::Other);
SDValue Ops[] = {Ld->getChain(), Ld->getBasePtr()};
SDValue BcastLd =
DAG.getMemIntrinsicNode(X86ISD::SUBV_BROADCAST_LOAD, DL, Tys, Ops,
Ld->getMemoryVT(), Ld->getMemOperand());
DAG.ReplaceAllUsesOfValueWith(
Op0,
extractSubVector(BcastLd, 0, DAG, DL, Op0.getValueSizeInBits()));
DAG.ReplaceAllUsesOfValueWith(SDValue(Ld, 1), BcastLd.getValue(1));
return BcastLd;
}
}

// concat_vectors(movddup(x),movddup(x)) -> broadcast(x)
if (Op0.getOpcode() == X86ISD::MOVDDUP && VT == MVT::v4f64 &&
(Subtarget.hasAVX2() ||
Expand Down

0 comments on commit 53900a1

Please sign in to comment.