[llvm] [CodeGen] Add early-exit to getFoldedSpillSize (PR #192201)
Cullen Rhodes via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 00:17:45 PDT 2026
https://github.com/c-rhodes created https://github.com/llvm/llvm-project/pull/192201
TargetInstrInfo::hasStoreToStackSlot is showing up in compile-time profiles of sqlite via MachineInstr::getFoldedSpillSize. Adding an early-exit for non-store instructions is a small win on this and some other workloads on stage1-aarch64-O0-g.
https://llvm-compile-time-tracker.com/compare.php?from=215f35eb8f1c313ac135ad47db1cc0b99b3ae694&to=4d8ce0a2e30829976c03a9e90b2dc56ab9b60646&stat=instructions%3Au
>From 266771b3c01161c111806147874d6b30057a4936 Mon Sep 17 00:00:00 2001
From: Cullen Rhodes <cullen.rhodes at arm.com>
Date: Mon, 13 Apr 2026 15:49:39 +0000
Subject: [PATCH] [CodeGen] Add early-exit to getFoldedSpillSize
TargetInstrInfo::hasStoreToStackSlot is showing up in compile-time
profiles of sqlite via MachineInstr::getFoldedSpillSize. Adding an
early-exit for non-store instructions is a small win on this and some
other workloads on stage1-aarch64-O0-g.
https://llvm-compile-time-tracker.com/compare.php?from=215f35eb8f1c313ac135ad47db1cc0b99b3ae694&to=4d8ce0a2e30829976c03a9e90b2dc56ab9b60646&stat=instructions%3Au
---
llvm/lib/CodeGen/MachineInstr.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 1042856454adf..cc3dae91c16d2 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -2613,6 +2613,9 @@ MachineInstr::getSpillSize(const TargetInstrInfo *TII) const {
std::optional<LocationSize>
MachineInstr::getFoldedSpillSize(const TargetInstrInfo *TII) const {
+ if (!mayStore())
+ return std::nullopt;
+
MMOList Accesses;
if (TII->hasStoreToStackSlot(*this, Accesses))
return getSpillSlotSize(Accesses, getMF()->getFrameInfo());
More information about the llvm-commits
mailing list