[llvm] [AArch64] Disable red-zone when lowering Q-reg copy through memory. (PR #94962)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 04:10:25 PDT 2024


https://github.com/sdesmalen-arm created https://github.com/llvm/llvm-project/pull/94962

This was pointed out in PR #93940.

>From 8e2a8c203a2821288d543da119f48751b3c8ad02 Mon Sep 17 00:00:00 2001
From: Sander de Smalen <sander.desmalen at arm.com>
Date: Mon, 10 Jun 2024 11:06:14 +0000
Subject: [PATCH] [AArch64] Disable red-zone when lowering Q-reg copy through
 memory.

This was pointed out in PR #93940.
---
 llvm/lib/Target/AArch64/AArch64FrameLowering.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index cd532671f5018..65e3bbf4e9c35 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -431,8 +431,15 @@ bool AArch64FrameLowering::canUseRedZone(const MachineFunction &MF) const {
   const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
   uint64_t NumBytes = AFI->getLocalStackSize();
 
+  // If neither NEON or SVE are available, a COPY from one Q-reg to
+  // another requires a spill -> reload sequence. We can do that
+  // using a pre-decrementing store/post-decrementing load, but
+  // if we do so, we can't use the Red Zone.
+  bool LowerQRegCopyThroughMem =
+      !Subtarget.isNeonAvailable() && !Subtarget.hasSVE();
+
   return !(MFI.hasCalls() || hasFP(MF) || NumBytes > RedZoneSize ||
-           getSVEStackSize(MF));
+           getSVEStackSize(MF) || LowerQRegCopyThroughMem);
 }
 
 /// hasFP - Return true if the specified function should have a dedicated frame



More information about the llvm-commits mailing list