Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 1 addition & 2 deletions llvm/include/llvm/CodeGen/CalcSpillWeights.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class VirtRegMap;
const MachineRegisterInfo &MRI);

/// Determine if all values in LI are rematerializable.
static bool isRematerializable(const LiveInterval &LI,
const LiveIntervals &LIS,
static bool isRematerializable(const LiveInterval &LI, LiveIntervals &LIS,
const VirtRegMap &VRM,
const TargetInstrInfo &TII);

Expand Down
16 changes: 15 additions & 1 deletion llvm/lib/CodeGen/CalcSpillWeights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/CodeGen/LiveInterval.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/LiveRangeEdit.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
Expand Down Expand Up @@ -79,7 +80,7 @@ Register VirtRegAuxInfo::copyHint(const MachineInstr *MI, Register Reg,

// Check if all values in LI are rematerializable
bool VirtRegAuxInfo::isRematerializable(const LiveInterval &LI,
const LiveIntervals &LIS,
LiveIntervals &LIS,
const VirtRegMap &VRM,
const TargetInstrInfo &TII) {
Register Reg = LI.reg();
Expand Down Expand Up @@ -124,6 +125,19 @@ bool VirtRegAuxInfo::isRematerializable(const LiveInterval &LI,

if (!TII.isTriviallyReMaterializable(*MI))
return false;

// If MI has register uses, it will only be rematerializable if its uses are
// also live at the indices it will be rematerialized at.
SmallVector<Register, 8> NewRegs;
LiveRangeEdit LRE(nullptr, NewRegs, *MI->getMF(), LIS, nullptr);
const MachineRegisterInfo &MRI = MI->getMF()->getRegInfo();
for (MachineInstr &Use : MRI.use_nodbg_instructions(Reg)) {
SlotIndex UseIdx = LIS.getInstructionIndex(Use);
if (LI.getVNInfoAt(UseIdx) != VNI)
continue;
if (!LRE.allUsesAvailableAt(MI, VNI->def, UseIdx))
return false;
}
}
return true;
}
Expand Down
48,523 changes: 24,362 additions & 24,161 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.1024bit.ll

Large diffs are not rendered by default.

7,844 changes: 3,507 additions & 4,337 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.512bit.ll

Large diffs are not rendered by default.

Loading