[llvm] 84df412 - [CodeGen] Adjust global-split remat heuristic to match LICM (#160709)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 06:53:26 PDT 2025


Author: Philip Reames
Date: 2025-09-26T06:53:21-07:00
New Revision: 84df4123e645ad93839e5b5b48c9f94bdd27a6e1

URL: https://github.com/llvm/llvm-project/commit/84df4123e645ad93839e5b5b48c9f94bdd27a6e1
DIFF: https://github.com/llvm/llvm-project/commit/84df4123e645ad93839e5b5b48c9f94bdd27a6e1.diff

LOG: [CodeGen] Adjust global-split remat heuristic to match LICM (#160709)

This heuristic was originally added in 40c4aa with the stated purpose of
avoiding global split on live long ranges created by MachineLICM
hoisting trivially rematerializable instructions. In the meantime,
various backends have introduced non-trivial rematerialization cases,
MachineLICM gained an explicitly triviality check, and we've reworked
our APIs to match naming wise. Let's move this heuristic back to truely
trivial remat only.

This is a functional change, though somewhat hard to hit. This change
will cause non-trivially rematerializable instructions to be globally
split more often. This is likely a good thing since non-trivial remat
may not be legal at all possible points in the live interval, but may
cost slightly more compile time.

I don't have a motivating example; I found it when reviewing the callers
of isRemMaterializable(MI).

Added: 
    

Modified: 
    llvm/lib/CodeGen/TargetRegisterInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp
index 2e473c6c4e97f..c9e46182decc2 100644
--- a/llvm/lib/CodeGen/TargetRegisterInfo.cpp
+++ b/llvm/lib/CodeGen/TargetRegisterInfo.cpp
@@ -67,7 +67,8 @@ bool TargetRegisterInfo::shouldRegionSplitForVirtReg(
   const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
   const MachineRegisterInfo &MRI = MF.getRegInfo();
   MachineInstr *MI = MRI.getUniqueVRegDef(VirtReg.reg());
-  if (MI && TII->isReMaterializable(*MI) && VirtReg.size() > HugeSizeForSplit)
+  if (MI && TII->isTriviallyReMaterializable(*MI) &&
+      VirtReg.size() > HugeSizeForSplit)
     return false;
   return true;
 }


        


More information about the llvm-commits mailing list