Skip to content

Commit 6c47182

Browse files
committed
[RegAlloc] Allow rematerialization with virtual reg uses
Stacked on #159180. Unless overridden by the target, we currently only allow rematerlization of instructions with immediate or constant physical register operands, i.e. no virtual registers. The comment states that this is because we might increase a live range of the virtual register, but we don't actually do this. LiveRangeEdit::allUsesAvailableAt makes sure that we only rematerialize instructions whose virtual registers are already live at the use sites. This patch relaxes this constraint which reduces a significant amount of reloads across various targets. This is another attempt at https://reviews.llvm.org/D106408, but #159180 aims to have addressed the issue with the weights that may have caused the previous regressions.
1 parent 048922e commit 6c47182

28 files changed

+1320
-1347
lines changed

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,12 +1657,6 @@ bool TargetInstrInfo::isReMaterializableImpl(
16571657
// same virtual register, though.
16581658
if (MO.isDef() && Reg != DefReg)
16591659
return false;
1660-
1661-
// Don't allow any virtual-register uses. Rematting an instruction with
1662-
// virtual register uses would length the live ranges of the uses, which
1663-
// is not necessarily a good idea, certainly not "trivial".
1664-
if (MO.isUse())
1665-
return false;
16661660
}
16671661

16681662
// Everything checked out.

0 commit comments

Comments
 (0)