[llvm] [SelectionDAG] Provide context for vector count / type mismatch (PR #175433)
Trevor Gross via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 11 04:38:48 PST 2026
https://github.com/tgross35 updated https://github.com/llvm/llvm-project/pull/175433
>From 7573d0f3ac79320e5ad2b0f6ffd3c3af5097fbf2 Mon Sep 17 00:00:00 2001
From: Trevor Gross <tg at trevorgross.com>
Date: Sun, 11 Jan 2026 01:26:43 -0500
Subject: [PATCH] [SelectionDAG] Provide context for vector count / type
mismatch
This now gives better details about what the mismatch is, e.g.:
---
llvm/include/llvm/CodeGenTypes/MachineValueType.h | 3 +++
.../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 13 ++++++++++---
llvm/lib/CodeGen/ValueTypes.cpp | 14 ++++++++------
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/llvm/include/llvm/CodeGenTypes/MachineValueType.h b/llvm/include/llvm/CodeGenTypes/MachineValueType.h
index 08a9c85a213e0..64687d515d21a 100644
--- a/llvm/include/llvm/CodeGenTypes/MachineValueType.h
+++ b/llvm/include/llvm/CodeGenTypes/MachineValueType.h
@@ -64,6 +64,9 @@ namespace llvm {
bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
+ /// Return the value type as a string, e.g. `i32`.
+ std::string getString() const;
+
/// Support for debugging, callable in GDB: VT.dump()
LLVM_ABI void dump() const;
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index bff4799963fc2..e21940e7aae85 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -769,9 +769,16 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL,
NumIntermediates, RegisterVT);
}
- assert(NumRegs == NumParts && "Part count doesn't match vector breakdown!");
- NumParts = NumRegs; // Silence a compiler warning.
- assert(RegisterVT == PartVT && "Part type doesn't match vector breakdown!");
+ if (NumRegs != NumParts || RegisterVT != PartVT)
+ report_fatal_error(Twine("Part count doesn't match vector breakdown! ")
+ .concat(Twine(NumRegs))
+ .concat(" registers, ")
+ .concat(Twine(NumParts))
+ .concat(" parts, ")
+ .concat(Twine(RegisterVT.getString()))
+ .concat(" RegisterVT, ")
+ .concat(Twine(PartVT.getString()))
+ .concat(" PartVT"));
assert(IntermediateVT.isScalableVector() == ValueVT.isScalableVector() &&
"Mixing scalable and fixed vectors when copying in parts");
diff --git a/llvm/lib/CodeGen/ValueTypes.cpp b/llvm/lib/CodeGen/ValueTypes.cpp
index 0743c92c5b95b..f3e4eaa2ef00f 100644
--- a/llvm/lib/CodeGen/ValueTypes.cpp
+++ b/llvm/lib/CodeGen/ValueTypes.cpp
@@ -333,6 +333,13 @@ const fltSemantics &EVT::getFltSemantics() const {
return getScalarType().getSimpleVT().getFltSemantics();
}
+std::string MVT::getString() const {
+ if (SimpleTy == INVALID_SIMPLE_VALUE_TYPE)
+ return "invalid";
+
+ return EVT(*this).getEVTString();
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void MVT::dump() const {
print(dbgs());
@@ -340,9 +347,4 @@ void MVT::dump() const {
}
#endif
-void MVT::print(raw_ostream &OS) const {
- if (SimpleTy == INVALID_SIMPLE_VALUE_TYPE)
- OS << "invalid";
- else
- OS << EVT(*this).getEVTString();
-}
+void MVT::print(raw_ostream &OS) const { OS << getString(); }
More information about the llvm-commits
mailing list