Skip to content

Commit 4676fef

Browse files
committed
[RegAlloc] Add a flag to toggle non-trivial rematerialization
1 parent ad29838 commit 4676fef

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static cl::opt<unsigned int> MaxAccumulatorWidth(
5656
"acc-max-width", cl::Hidden, cl::init(3),
5757
cl::desc("Maximum number of branches in the accumulator tree"));
5858

59+
static cl::opt<bool> AllowNTRemat(
60+
"allow-none-trival-remat", cl::init(true), cl::Hidden,
61+
cl::desc("Allow non-trivial rematerialization by default"));
62+
5963
TargetInstrInfo::~TargetInstrInfo() = default;
6064

6165
const TargetRegisterClass *
@@ -1657,6 +1661,14 @@ bool TargetInstrInfo::isReMaterializableImpl(
16571661
// same virtual register, though.
16581662
if (MO.isDef() && Reg != DefReg)
16591663
return false;
1664+
1665+
// Don't allow any virtual-register uses. Rematting an instruction with
1666+
// virtual register uses would length the live ranges of the uses, which
1667+
// is not necessarily a good idea, certainly not "trivial".
1668+
if (!AllowNTRemat) {
1669+
if (MO.isUse())
1670+
return false;
1671+
}
16601672
}
16611673

16621674
// Everything checked out.

0 commit comments

Comments
 (0)