[llvm] [AArch64] Add a fast-path for AArch64InstrInfo::getInstSizeInBytes (NFC) (PR #221894)
Cullen Rhodes via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 00:21:53 PDT 2026
https://github.com/c-rhodes created https://github.com/llvm/llvm-project/pull/221894
Improves CTMark geomean -0.07% on aarch64-O0-g.
https://llvm-compile-time-tracker.com/compare.php?from=97cbc1e404b980edc58bfbcabb6f1c61793b624b&to=be1403a1f2db85c9443fa8300fa8522561bea90a&stat=instructions:u
Assisted-by: codex
>From be1403a1f2db85c9443fa8300fa8522561bea90a Mon Sep 17 00:00:00 2001
From: Cullen Rhodes <cullen.rhodes at arm.com>
Date: Tue, 28 Apr 2026 19:21:46 +0000
Subject: [PATCH] [AArch64] Add a fast-path for
AArch64InstrInfo::getInstSizeInBytes (NFC)
Assisted-by: codex
---
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index e69336ea04857..35fc9a67e1304 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -204,6 +204,10 @@ static std::optional<unsigned> getLFIInstSizeInBytes(const MachineInstr &MI) {
/// GetInstSize - Return the number of bytes of code the specified
/// instruction may be. This returns the maximum number of bytes.
unsigned AArch64InstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
+ const MCInstrDesc &Desc = MI.getDesc();
+ if (!Desc.isPseudo() && !Subtarget.isLFI())
+ return 4;
+
const MachineBasicBlock &MBB = *MI.getParent();
const MachineFunction *MF = MBB.getParent();
const Function &F = MF->getFunction();
@@ -222,7 +226,6 @@ unsigned AArch64InstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
// FIXME: We currently only handle pseudoinstructions that don't get expanded
// before the assembly printer.
unsigned NumBytes = 0;
- const MCInstrDesc &Desc = MI.getDesc();
// LFI rewriter expansions that supersede normal sizing.
const auto &STI = MF->getSubtarget<AArch64Subtarget>();
More information about the llvm-commits
mailing list