From edb45d8ae4b3f4cad257e509db2e01e84bf0aa84 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 9 Dec 2025 12:18:21 +0100 Subject: [PATCH] [SDAG] Allow implicit trunc in BUILD_VECTOR legalization BUILD_VECTOR may have operands larger than the result element type, in which case it is specified to truncate. As such, allow implicit truncation. --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 1630dd783e82..fc3e9ff0d623 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -2051,7 +2051,8 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { // we don't want a v16i8 to become a v16i32 for example. const ConstantInt *CI = V->getConstantIntValue(); CV.push_back(ConstantInt::get(EltVT.getTypeForEVT(*DAG.getContext()), - CI->getZExtValue())); + CI->getZExtValue(), /*IsSigned=*/false, + /*ImplicitTrunc=*/true)); } } else { assert(Node->getOperand(i).isUndef());