mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Factor out LiveIntervalAnalysis' code to determine whether an instruction
is trivially rematerializable and integrate it into TargetInstrInfo::isTriviallyReMaterializable. This way, all places that need to know whether an instruction is rematerializable will get the same answer. This enables the useful parts of the aggressive-remat option by default -- using AliasAnalysis to determine whether a memory location is invariant, and removes the questionable parts -- rematting operations with virtual register inputs that may not be live everywhere. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -34,6 +34,7 @@
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
@ -62,6 +63,7 @@ namespace {
|
||||
const TargetRegisterInfo *TRI;
|
||||
MachineRegisterInfo *MRI;
|
||||
LiveVariables *LV;
|
||||
AliasAnalysis *AA;
|
||||
|
||||
// DistanceMap - Keep track the distance of a MI from the start of the
|
||||
// current basic block.
|
||||
@ -130,6 +132,7 @@ namespace {
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesCFG();
|
||||
AU.addRequired<AliasAnalysis>();
|
||||
AU.addPreserved<LiveVariables>();
|
||||
AU.addPreservedID(MachineLoopInfoID);
|
||||
AU.addPreservedID(MachineDominatorsID);
|
||||
@ -160,7 +163,7 @@ bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB,
|
||||
MachineBasicBlock::iterator OldPos) {
|
||||
// Check if it's safe to move this instruction.
|
||||
bool SeenStore = true; // Be conservative.
|
||||
if (!MI->isSafeToMove(TII, SeenStore))
|
||||
if (!MI->isSafeToMove(TII, SeenStore, AA))
|
||||
return false;
|
||||
|
||||
unsigned DefReg = 0;
|
||||
@ -903,6 +906,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
TII = TM.getInstrInfo();
|
||||
TRI = TM.getRegisterInfo();
|
||||
LV = getAnalysisIfAvailable<LiveVariables>();
|
||||
AA = &getAnalysis<AliasAnalysis>();
|
||||
|
||||
bool MadeChange = false;
|
||||
|
||||
@ -1027,7 +1031,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
// copying it.
|
||||
if (DefMI &&
|
||||
DefMI->getDesc().isAsCheapAsAMove() &&
|
||||
DefMI->isSafeToReMat(TII, regB) &&
|
||||
DefMI->isSafeToReMat(TII, regB, AA) &&
|
||||
isProfitableToReMat(regB, rc, mi, DefMI, mbbi, Dist)){
|
||||
DEBUG(errs() << "2addr: REMATTING : " << *DefMI << "\n");
|
||||
unsigned regASubIdx = mi->getOperand(DstIdx).getSubReg();
|
||||
|
Reference in New Issue
Block a user