[llvm] 1f15665 - [AArch64] Add a fast-path for AArch64InstrInfo::getInstSizeInBytes (NFC) (#221894)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 02:53:25 PDT 2026


Author: Cullen Rhodes
Date: 2026-09-08T10:53:19+01:00
New Revision: 1f15665245afc1b303ed2cad0c5ea610f499f666

URL: https://github.com/llvm/llvm-project/commit/1f15665245afc1b303ed2cad0c5ea610f499f666
DIFF: https://github.com/llvm/llvm-project/commit/1f15665245afc1b303ed2cad0c5ea610f499f666.diff

LOG: [AArch64] Add a fast-path for AArch64InstrInfo::getInstSizeInBytes (NFC) (#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

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 47b2a616fc0a1..90c6ca1d11b7c 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -204,6 +204,12 @@ 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()) {
+    assert(Desc.getSize() == 4 && "Unexpected instruction size");
+    return 4;
+  }
+
   const MachineBasicBlock &MBB = *MI.getParent();
   const MachineFunction *MF = MBB.getParent();
   const Function &F = MF->getFunction();
@@ -222,7 +228,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