[llvm] [X86] Enable spillage copy elimination on X86 (PR #155868)

Thor Preimesberger via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 08:57:38 PDT 2025


https://github.com/cheezeburglar created https://github.com/llvm/llvm-project/pull/155868

RAGreedy sometimes generates spill-reload chains such as in #136574; there is machinery in MachineCopyPropagation::EliminateSpillageCopies that eliminates these meaningless movs. Here we just enable it by default on X86.

Old code in RAGreedy that removed tried to prevent these chains are [here](https://github.com/llvm/llvm-project/commit/294eca35a00f89dff474044ebd478a7f83ccc310); gonna remove draft status after checking for perfomance regressions. Tests OK on my machine.

>From 4ddc96de0fa3844c375cf0fa2d3aece2ab7b7e0d Mon Sep 17 00:00:00 2001
From: Thor Preimesberger <ThorP at protonmail.com>
Date: Mon, 25 Aug 2025 15:06:23 -0400
Subject: [PATCH] [X86] Enable spillage copy elimination on X86

---
 llvm/lib/Target/X86/X86Subtarget.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h
index be49214e041ea..42bd0b67aed78 100644
--- a/llvm/lib/Target/X86/X86Subtarget.h
+++ b/llvm/lib/Target/X86/X86Subtarget.h
@@ -422,6 +422,8 @@ class X86Subtarget final : public X86GenSubtargetInfo {
 
   bool enableEarlyIfConversion() const override;
 
+  bool enableSpillageCopyElimination() const override { return true; }
+
   void getPostRAMutations(std::vector<std::unique_ptr<ScheduleDAGMutation>>
                               &Mutations) const override;
 



More information about the llvm-commits mailing list