Skip to content

Commit a8f6de6

Browse files
RKSimonjoaosaffran
authored and
joaosaffran
committed
[X86] Merge insertsubvector(load(p0),load_subv(p0),hi) -> subvbroadcast(p0) if either load is oneuse (llvm#128857)
This fold is currently limited to cases where the load_subv(p0) has oneuse, but its beneficial if either load has oneuse and will be replaced. Yet another yak shave for llvm#122671
1 parent 3ce0280 commit a8f6de6

File tree

2 files changed

+527
-544
lines changed

2 files changed

+527
-544
lines changed

Diff for: llvm/lib/Target/X86/X86ISelLowering.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -58564,15 +58564,22 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5856458564

5856558565
// If we're splatting the lower half subvector of a full vector load into the
5856658566
// upper half, attempt to create a subvector broadcast.
58567-
if (IdxVal == (OpVT.getVectorNumElements() / 2) && SubVec.hasOneUse() &&
58568-
Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits())) {
58567+
// TODO: Drop hasOneUse checks.
58568+
if (IdxVal == (OpVT.getVectorNumElements() / 2) &&
58569+
Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits()) &&
58570+
(Vec.hasOneUse() || SubVec.hasOneUse())) {
5856958571
auto *VecLd = dyn_cast<LoadSDNode>(Vec);
5857058572
auto *SubLd = dyn_cast<LoadSDNode>(SubVec);
5857158573
if (VecLd && SubLd &&
58572-
DAG.areNonVolatileConsecutiveLoads(SubLd, VecLd,
58573-
SubVec.getValueSizeInBits() / 8, 0))
58574-
return getBROADCAST_LOAD(X86ISD::SUBV_BROADCAST_LOAD, dl, OpVT, SubVecVT,
58575-
SubLd, 0, DAG);
58574+
DAG.areNonVolatileConsecutiveLoads(
58575+
SubLd, VecLd, SubVec.getValueSizeInBits() / 8, 0)) {
58576+
SDValue BcastLd = getBROADCAST_LOAD(X86ISD::SUBV_BROADCAST_LOAD, dl, OpVT,
58577+
SubVecVT, SubLd, 0, DAG);
58578+
SDValue NewSubVec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, SubVecVT,
58579+
BcastLd, DAG.getVectorIdxConstant(0, dl));
58580+
DCI.CombineTo(SubLd, NewSubVec, BcastLd.getValue(1));
58581+
return BcastLd;
58582+
}
5857658583
}
5857758584

5857858585
return SDValue();

0 commit comments

Comments
 (0)