Skip to content

Commit 4e4f3f1

Browse files
preamesmahesh-attarde
authored andcommitted
[CodeGen] Adjust global-split remat heuristic to match LICM (llvm#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).
1 parent 8404e27 commit 4e4f3f1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/CodeGen/TargetRegisterInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ bool TargetRegisterInfo::shouldRegionSplitForVirtReg(
6767
const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
6868
const MachineRegisterInfo &MRI = MF.getRegInfo();
6969
MachineInstr *MI = MRI.getUniqueVRegDef(VirtReg.reg());
70-
if (MI && TII->isReMaterializable(*MI) && VirtReg.size() > HugeSizeForSplit)
70+
if (MI && TII->isTriviallyReMaterializable(*MI) &&
71+
VirtReg.size() > HugeSizeForSplit)
7172
return false;
7273
return true;
7374
}

0 commit comments

Comments
 (0)