mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
Disable expensive two-address optimizations at -O0. rdar://10453055
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144806 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -68,6 +68,7 @@ namespace {
|
|||||||
MachineRegisterInfo *MRI;
|
MachineRegisterInfo *MRI;
|
||||||
LiveVariables *LV;
|
LiveVariables *LV;
|
||||||
AliasAnalysis *AA;
|
AliasAnalysis *AA;
|
||||||
|
CodeGenOpt::Level OptLevel;
|
||||||
|
|
||||||
// DistanceMap - Keep track the distance of a MI from the start of the
|
// DistanceMap - Keep track the distance of a MI from the start of the
|
||||||
// current basic block.
|
// current basic block.
|
||||||
@@ -571,6 +572,9 @@ bool
|
|||||||
TwoAddressInstructionPass::isProfitableToCommute(unsigned regB, unsigned regC,
|
TwoAddressInstructionPass::isProfitableToCommute(unsigned regB, unsigned regC,
|
||||||
MachineInstr *MI, MachineBasicBlock *MBB,
|
MachineInstr *MI, MachineBasicBlock *MBB,
|
||||||
unsigned Dist) {
|
unsigned Dist) {
|
||||||
|
if (OptLevel == CodeGenOpt::None)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Determine if it's profitable to commute this two address instruction. In
|
// Determine if it's profitable to commute this two address instruction. In
|
||||||
// general, we want no uses between this instruction and the definition of
|
// general, we want no uses between this instruction and the definition of
|
||||||
// the two-address register.
|
// the two-address register.
|
||||||
@@ -1193,6 +1197,9 @@ TryInstructionTransform(MachineBasicBlock::iterator &mi,
|
|||||||
MachineFunction::iterator &mbbi,
|
MachineFunction::iterator &mbbi,
|
||||||
unsigned SrcIdx, unsigned DstIdx, unsigned Dist,
|
unsigned SrcIdx, unsigned DstIdx, unsigned Dist,
|
||||||
SmallPtrSet<MachineInstr*, 8> &Processed) {
|
SmallPtrSet<MachineInstr*, 8> &Processed) {
|
||||||
|
if (OptLevel == CodeGenOpt::None)
|
||||||
|
return false;
|
||||||
|
|
||||||
MachineInstr &MI = *mi;
|
MachineInstr &MI = *mi;
|
||||||
const MCInstrDesc &MCID = MI.getDesc();
|
const MCInstrDesc &MCID = MI.getDesc();
|
||||||
unsigned regA = MI.getOperand(DstIdx).getReg();
|
unsigned regA = MI.getOperand(DstIdx).getReg();
|
||||||
@@ -1388,6 +1395,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
InstrItins = TM.getInstrItineraryData();
|
InstrItins = TM.getInstrItineraryData();
|
||||||
LV = getAnalysisIfAvailable<LiveVariables>();
|
LV = getAnalysisIfAvailable<LiveVariables>();
|
||||||
AA = &getAnalysis<AliasAnalysis>();
|
AA = &getAnalysis<AliasAnalysis>();
|
||||||
|
OptLevel = TM.getOptLevel();
|
||||||
|
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
|
@@ -82,9 +82,8 @@ define i64 @test5(i8* %A, i32 %I, i64 %B) nounwind {
|
|||||||
ret i64 %v11
|
ret i64 %v11
|
||||||
; X64: test5:
|
; X64: test5:
|
||||||
; X64: movslq %e[[A1]], %rax
|
; X64: movslq %e[[A1]], %rax
|
||||||
; X64-NEXT: movq (%r[[A0]],%rax), %rax
|
; X64-NEXT: (%r[[A0]],%rax),
|
||||||
; X64-NEXT: addq %{{rdx|r8}}, %rax
|
; X64: ret
|
||||||
; X64-NEXT: ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
; PR9500, rdar://9156159 - Don't do non-local address mode folding,
|
; PR9500, rdar://9156159 - Don't do non-local address mode folding,
|
||||||
|
@@ -82,7 +82,7 @@ entry:
|
|||||||
ret i64 %mul
|
ret i64 %mul
|
||||||
|
|
||||||
; CHECK: test6:
|
; CHECK: test6:
|
||||||
; CHECK: leaq (,%rdi,8), %rax
|
; CHECK: shlq $3, %rdi
|
||||||
}
|
}
|
||||||
|
|
||||||
define i32 @test7(i32 %x) nounwind ssp {
|
define i32 @test7(i32 %x) nounwind ssp {
|
||||||
@@ -90,7 +90,7 @@ entry:
|
|||||||
%mul = mul nsw i32 %x, 8
|
%mul = mul nsw i32 %x, 8
|
||||||
ret i32 %mul
|
ret i32 %mul
|
||||||
; CHECK: test7:
|
; CHECK: test7:
|
||||||
; CHECK: leal (,%rdi,8), %eax
|
; CHECK: shll $3, %edi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user