[llvm] [SelectionDAG] Fold VECREDUCE_ADD of a constant BUILD_VECTOR (PR #207560)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 04:21:22 PDT 2026
================
@@ -7797,6 +7786,19 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
// Early-out if we failed to constant fold a bitcast.
if (Opcode == ISD::BITCAST)
return SDValue();
+
+ // Constant fold VECREDUCE_ADD with a BUILD_VECTOR of integer constants.
+ if (Opcode == ISD::VECREDUCE_ADD && N1.getOpcode() == ISD::BUILD_VECTOR &&
+ ISD::isBuildVectorOfConstantSDNodes(N1.getNode())) {
----------------
RKSimon wrote:
"N1.getOpcode() == ISD::BUILD_VECTOR" is superfluous as its first thing that isBuildVectorOfConstantSDNodes checks
https://github.com/llvm/llvm-project/pull/207560
More information about the llvm-commits
mailing list