[llvm] [MachineLICM] Let targets decide if copy-like instructions are cheap (PR #146599)
Guy David via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 4 08:40:26 PDT 2025
https://github.com/guy-david updated https://github.com/llvm/llvm-project/pull/146599
>From 1a300af99f98cac800c7318cb95ef3e33a4457b3 Mon Sep 17 00:00:00 2001
From: Guy David <guyda96 at gmail.com>
Date: Fri, 4 Jul 2025 18:30:42 +0300
Subject: [PATCH] [MachineLICM] Let targets decide if copy-like instructions
are cheap
When checking whether it is profitable to hoist an instruction, the pass
may override a target's ruling because it assumes that all COPY
instructions are cheap, and that may not be the case for all
micro-architectures.
On AArch64 there's 0% difference in performance in LLVM's test-suite.
---
llvm/lib/CodeGen/MachineLICM.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 699d7ab175568..f1811c47e5ad4 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -1219,7 +1219,7 @@ bool MachineLICMImpl::HasHighOperandLatency(MachineInstr &MI, unsigned DefIdx,
/// Return true if the instruction is marked "cheap" or the operand latency
/// between its def and a use is one or less.
bool MachineLICMImpl::IsCheapInstruction(MachineInstr &MI) const {
- if (TII->isAsCheapAsAMove(MI) || MI.isCopyLike())
+ if (TII->isAsCheapAsAMove(MI) || MI.isSubregToReg())
return true;
bool isCheap = false;
More information about the llvm-commits
mailing list