Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions llvm/lib/CodeGen/TargetInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ static cl::opt<unsigned int> MaxAccumulatorWidth(
"acc-max-width", cl::Hidden, cl::init(3),
cl::desc("Maximum number of branches in the accumulator tree"));

static cl::opt<bool>
AllowNTRemat("allow-none-trival-remat", cl::init(true), cl::Hidden,
cl::desc("Allow non-trivial rematerialization by default"));

TargetInstrInfo::~TargetInstrInfo() = default;

const TargetRegisterClass *
Expand Down Expand Up @@ -1657,6 +1661,14 @@ bool TargetInstrInfo::isReMaterializableImpl(
// same virtual register, though.
if (MO.isDef() && Reg != DefReg)
return false;

// Don't allow any virtual-register uses. Rematting an instruction with
// virtual register uses would length the live ranges of the uses, which
// is not necessarily a good idea, certainly not "trivial".
if (!AllowNTRemat) {
if (MO.isUse())
return false;
}
}

// Everything checked out.
Expand Down