[llvm] [RegisterCoalescer] Prefer copy over rematerialization when smaller (PR #182279)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 19 07:26:43 PST 2026
================
@@ -1319,6 +1319,15 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
if (!TII->isReMaterializable(*DefMI))
return false;
+ // For multiple uses of a cheap instruction, prefer to copy if it affects code
+ // size.
+ if (!MRI->hasOneNonDBGUse(SrcReg)) {
+ unsigned RematSize = TII->getInstSizeInBytes(*DefMI);
----------------
arsenm wrote:
Does getInstSizeInBytes even work correctly for pseudoinstructions? I'm pretty sure the AMDGPU implementation will get the wrong answer, at least.
I'm not sure this make sense unless maybe you're using minsize? The spill code you're increasing the chances of emitting may be larger
https://github.com/llvm/llvm-project/pull/182279
More information about the llvm-commits
mailing list