[llvm] [AArch64][GISel] Skip SME call-attr checks on non-SME targets (PR #190135)

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 03:45:44 PDT 2026


https://github.com/c-rhodes updated https://github.com/llvm/llvm-project/pull/190135

>From ba75f8fe1f0e44f7456dd282e066b6d6e781ada3 Mon Sep 17 00:00:00 2001
From: Cullen Rhodes <cullen.rhodes at arm.com>
Date: Thu, 2 Apr 2026 08:08:51 +0000
Subject: [PATCH 1/2] [AArch64][GISel] Skip SME call-attr checks on non-SME
 targets

`fallBackToDAGISel` was constructing `SMECallAttrs` for every call even
when the subtarget had no SME/SME2 support. This shows up in
compile-time profiles without ever triggering a fallback.
---
 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 38db1ac4a2fb9..3089220b13719 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -31417,12 +31417,15 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
   }
 
   // Checks to allow the use of SME instructions
-  if (auto *Base = dyn_cast<CallBase>(&Inst)) {
-    auto CallAttrs = SMECallAttrs(*Base, &getRuntimeLibcallsInfo());
-    if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
-        CallAttrs.requiresPreservingZT0() ||
-        CallAttrs.requiresPreservingAllZAState())
-      return true;
+  // If the subtarget lacks SME/SME2 we can skip per-call SME attribute checks.
+  if (Subtarget->hasSME() || Subtarget->hasSME2()) {
+    if (auto *Base = dyn_cast<CallBase>(&Inst)) {
+      auto CallAttrs = SMECallAttrs(*Base, &getRuntimeLibcallsInfo());
+      if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
+          CallAttrs.requiresPreservingZT0() ||
+          CallAttrs.requiresPreservingAllZAState())
+        return true;
+    }
   }
   return false;
 }

>From 833783ba0bd1daaf1c68b8905d12875720c39c26 Mon Sep 17 00:00:00 2001
From: Cullen Rhodes <cullen.rhodes at arm.com>
Date: Thu, 2 Apr 2026 10:33:54 +0000
Subject: [PATCH 2/2] address comments

---
 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 3089220b13719..34019188e998d 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -31417,9 +31417,11 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
   }
 
   // Checks to allow the use of SME instructions
-  // If the subtarget lacks SME/SME2 we can skip per-call SME attribute checks.
-  if (Subtarget->hasSME() || Subtarget->hasSME2()) {
-    if (auto *Base = dyn_cast<CallBase>(&Inst)) {
+  if (auto *Base = dyn_cast<CallBase>(&Inst)) {
+    const Function *Caller = Base->getCaller();
+    if (Subtarget->hasSME() ||
+        Caller->hasFnAttribute("aarch64_pstate_sm_compatible") ||
+        Caller->hasFnAttribute("aarch64_za_state_agnostic")) {
       auto CallAttrs = SMECallAttrs(*Base, &getRuntimeLibcallsInfo());
       if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
           CallAttrs.requiresPreservingZT0() ||



More information about the llvm-commits mailing list