From 1a300af99f98cac800c7318cb95ef3e33a4457b3 Mon Sep 17 00:00:00 2001 From: Guy David 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;