[llvm] Update callers of isTriviallyReMaterializable to check trivialness (PR #160319)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 23 17:48:28 PDT 2025
================
@@ -260,7 +260,10 @@ static void query(const MachineInstr &MI, bool &Read, bool &Write,
// Test whether Def is safe and profitable to rematerialize.
static bool shouldRematerialize(const MachineInstr &Def,
const WebAssemblyInstrInfo *TII) {
- return Def.isAsCheapAsAMove() && TII->isTriviallyReMaterializable(Def);
+ return Def.isAsCheapAsAMove() && TII->isTriviallyReMaterializable(Def) &&
+ llvm::all_of(Def.all_uses(), [](const MachineOperand &MO) {
+ return MO.getReg().isVirtual();
+ });
----------------
arsenm wrote:
Should put this in a utility function somewhere
https://github.com/llvm/llvm-project/pull/160319
More information about the llvm-commits
mailing list