[llvm] [AMDGPU][X86][DAG] Avoid duplicate BinOp result from narrowing insert-extract sub-vector (PR #201056)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 05:48:38 PDT 2026
================
@@ -27267,36 +27295,106 @@ static SDValue narrowInsertExtractVectorBinOp(EVT SubVT, SDValue BinOp,
EVT VecVT = BinOp.getValueType();
SDValue Bop0 = BinOp.getOperand(0), Bop1 = BinOp.getOperand(1);
- if (VecVT != Bop0.getValueType() || VecVT != Bop1.getValueType())
+ if (VecVT != Bop0.getValueType() || VecVT != Bop1.getValueType() ||
+ VecVT.isScalableVT())
return SDValue();
- if (!TLI.isOperationLegalOrCustom(BinOpcode, SubVT, LegalOperations))
+
+ // This fold only pays off when the wide binop disappears completely, so every
+ // user must be an extract_subvector. Require them all to extract N's type so
+ // a single chain scan serves every extract, and seed the source map by index.
+ EVT SubVT = N->getValueType(0);
+ if (VecVT.getSizeInBits() <= SubVT.getSizeInBits())
return SDValue();
- SDValue Sub0 = getSubVectorSrc(Bop0, Index, SubVT);
- SDValue Sub1 = getSubVectorSrc(Bop1, Index, SubVT);
+ SmallMapVector<unsigned, std::tuple<SDNode *, SDValue, SDValue>, 4> Extracts;
----------------
arsenm wrote:
Feels like this shouldn't be a MapVector. You only have a small number of indexes to fill?
https://github.com/llvm/llvm-project/pull/201056
More information about the llvm-commits
mailing list