[llvm] AArch64: Guard optimizeCondBranch against a physical copy source (PR #216699)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 04:28:31 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/216699
optimizeCondBranch walks COPY chains from the branch condition register,
calling getVRegDef on each copy's source operand. A COPY source can be a
physical register which doesn't make sense to pass to getVRegDef.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
>From 55cd35876fa16ff399c95dba6344255e71799e82 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 17 Aug 2026 13:22:10 +0200
Subject: [PATCH] AArch64: Guard optimizeCondBranch against a physical copy
source
optimizeCondBranch walks COPY chains from the branch condition register,
calling getVRegDef on each copy's source operand. A COPY source can be a
physical register which doesn't make sense to pass to getVRegDef.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index bd4cacc737fd7..ced050e3bbd8a 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -10096,6 +10096,8 @@ bool AArch64InstrInfo::optimizeCondBranch(MachineInstr &MI) const {
// Look through COPY instructions to find definition.
while (DefMI->isCopy()) {
Register CopyVReg = DefMI->getOperand(1).getReg();
+ if (!CopyVReg.isVirtual())
+ return false;
if (!MRI->hasOneNonDBGUse(CopyVReg))
return false;
if (!MRI->hasOneDef(CopyVReg))
More information about the llvm-commits
mailing list