[llvm] [DAG] expandVecReduce - ensure widening to a wider vector type (PR #195251)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 04:09:52 PDT 2026


https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/195251

Add missing check in #194672 that the getTypeToTransformTo is actually WIDER than the half type

Test coverage will follow shortly in an upcoming x86 patch

>From 5898fb884eee9954c89a19a42816acc4cca5b303 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Fri, 1 May 2026 12:09:15 +0100
Subject: [PATCH] [DAG] expandVecReduce - ensure widening to a wider vector
 type

Add missing check in #194672 that the getTypeToTransformTo is actually WIDER than the half type

Test coverage will follow shortly in an upcoming x86 patch
---
 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index ac7a83f3ae998..31bea23efb9b3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -12272,6 +12272,7 @@ SDValue TargetLowering::expandVecReduce(SDNode *Node, SelectionDAG &DAG) const {
           EVT WideVT = getTypeToTransformTo(*DAG.getContext(), HalfVT);
           if (WideVT.isVector() &&
               WideVT.getScalarType() == HalfVT.getScalarType() &&
+              WideVT.getVectorNumElements() >= HalfVT.getVectorNumElements() &&
               isOperationLegalOrCustom(BaseOpcode, WideVT)) {
             SDValue Lo, Hi;
             std::tie(Lo, Hi) = DAG.SplitVector(Op, dl);



More information about the llvm-commits mailing list