aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2025-09-17 19:43:50 +0900
committerGitHub <noreply@github.com>2025-09-17 19:43:50 +0900
commit1dbb932fd8681930ed98fe621bbe4bdaa5aeaa5c (patch)
treefb378b3a7e2e0738de5dc16e644e576634dd93a6 /llvm/lib/CodeGen/MachineVerifier.cpp
parent9690a718b8d5344583eadfbc5bf2249d7d39b777 (diff)
downloadllvm-1dbb932fd8681930ed98fe621bbe4bdaa5aeaa5c.zip
llvm-1dbb932fd8681930ed98fe621bbe4bdaa5aeaa5c.tar.gz
llvm-1dbb932fd8681930ed98fe621bbe4bdaa5aeaa5c.tar.bz2
GlobalISel: Relax verifier between physreg and typed vreg (#159281)
Accept mismatched register size and type size if the type is legal for the register class. For AMDGPU boolean registers have 2 possible interpretations depending on the use context type. e.g., these are both equally valid: %0:_(s1) = COPY $vcc %1:_(s64) = COPY $vcc vcc is a 64-bit register, which can be interpreted as a 1-bit or 64-bit value depending on the use context. SelectionDAG has never required exact match between the register size and the used value type. You can assign a type with a smaller size to a larger register class. Relax the verifier to match. There are several hacks holding together these copies in various places, and this is preparation to remove one of them. The x86 test change is from what I would consider an X86 usage bug. X86 defines an FR32 register class and F16 register class, but the F16 register class is functionally an alias of F32 with the same members and size. There's no need to have the F16 class.
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 2b24fe4..e911ce8 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -2376,20 +2376,24 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
// If we have only one valid type, this is likely a copy between a virtual
// and physical register.
- TypeSize SrcSize = TRI->getRegSizeInBits(SrcReg, *MRI);
- TypeSize DstSize = TRI->getRegSizeInBits(DstReg, *MRI);
+ TypeSize SrcSize = TypeSize::getZero();
+ TypeSize DstSize = TypeSize::getZero();
if (SrcReg.isPhysical() && DstTy.isValid()) {
const TargetRegisterClass *SrcRC =
TRI->getMinimalPhysRegClassLLT(SrcReg, DstTy);
- if (SrcRC)
- SrcSize = TRI->getRegSizeInBits(*SrcRC);
+ if (!SrcRC)
+ SrcSize = TRI->getRegSizeInBits(SrcReg, *MRI);
+ } else {
+ SrcSize = TRI->getRegSizeInBits(SrcReg, *MRI);
}
if (DstReg.isPhysical() && SrcTy.isValid()) {
const TargetRegisterClass *DstRC =
TRI->getMinimalPhysRegClassLLT(DstReg, SrcTy);
- if (DstRC)
- DstSize = TRI->getRegSizeInBits(*DstRC);
+ if (!DstRC)
+ DstSize = TRI->getRegSizeInBits(DstReg, *MRI);
+ } else {
+ DstSize = TRI->getRegSizeInBits(DstReg, *MRI);
}
// The next two checks allow COPY between physical and virtual registers,