[llvm] [SelectionDAG][x86] Ensure vector reduction optimization (PR #144231)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 14 03:42:14 PST 2026
Suhajda =?utf-8?q?Tamás?= <sutajo at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/144231 at github.com>
================
@@ -48066,6 +48077,36 @@ static SDValue combineExtractVectorElt(SDNode *N, SelectionDAG &DAG,
return SDValue();
}
+static SDValue combineExtractVectorEltAndOperand(SDNode* N, SelectionDAG& DAG,
+ TargetLowering::DAGCombinerInfo& DCI,
+ const X86Subtarget& Subtarget)
+{
+ bool TransformedBinOpReduction = false;
+ auto Op = combineExtractVectorElt(N, DAG, DCI, Subtarget, TransformedBinOpReduction);
+
+ if (TransformedBinOpReduction)
+ {
+ // In case we simplified N = extract_vector_element(V, 0) with Op and V
+ // resulted from a reduction, then we need to replace all uses of V with
+ // scalar_to_vector(Op) to make sure that we eliminated the binop + shuffle
+ // pyramid. This is safe to do, because the elements of V are undefined except
+ // for the zeroth element and Op does not depend on V.
+
+ auto OldV = N->getOperand(0);
----------------
RKSimon wrote:
(style) don't use auto
https://github.com/llvm/llvm-project/pull/144231
More information about the llvm-commits
mailing list