mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 07:34:06 +00:00
Don't use floating point in SimpleRegisterCoalescing.
Rounding differences causes tests to fail on Linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102729 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5b296e307f
commit
132dace4aa
@ -1034,9 +1034,8 @@ SimpleRegisterCoalescing::isWinToJoinVRWithSrcPhysReg(MachineInstr *CopyMI,
|
|||||||
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
||||||
unsigned Length = li_->getApproximateInstructionCount(DstInt);
|
unsigned Length = li_->getApproximateInstructionCount(DstInt);
|
||||||
if (Length > Threshold &&
|
if (Length > Threshold &&
|
||||||
(((float)std::distance(mri_->use_nodbg_begin(DstInt.reg),
|
std::distance(mri_->use_nodbg_begin(DstInt.reg),
|
||||||
mri_->use_nodbg_end()) / Length) <
|
mri_->use_nodbg_end()) * Threshold < Length)
|
||||||
(1.0 / Threshold)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the virtual register live interval extends into a loop, turn down
|
// If the virtual register live interval extends into a loop, turn down
|
||||||
@ -1092,9 +1091,8 @@ SimpleRegisterCoalescing::isWinToJoinVRWithDstPhysReg(MachineInstr *CopyMI,
|
|||||||
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
||||||
unsigned Length = li_->getApproximateInstructionCount(SrcInt);
|
unsigned Length = li_->getApproximateInstructionCount(SrcInt);
|
||||||
if (Length > Threshold &&
|
if (Length > Threshold &&
|
||||||
(((float)std::distance(mri_->use_nodbg_begin(SrcInt.reg),
|
std::distance(mri_->use_nodbg_begin(SrcInt.reg),
|
||||||
mri_->use_nodbg_end()) / Length) <
|
mri_->use_nodbg_end()) * Threshold < Length)
|
||||||
(1.0 / Threshold)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (SrcInt.empty())
|
if (SrcInt.empty())
|
||||||
@ -1164,18 +1162,16 @@ SimpleRegisterCoalescing::isWinToJoinCrossClass(unsigned SrcReg,
|
|||||||
mri_->use_nodbg_end());
|
mri_->use_nodbg_end());
|
||||||
unsigned DstUses = std::distance(mri_->use_nodbg_begin(DstReg),
|
unsigned DstUses = std::distance(mri_->use_nodbg_begin(DstReg),
|
||||||
mri_->use_nodbg_end());
|
mri_->use_nodbg_end());
|
||||||
float NewDensity = ((float)(SrcUses + DstUses) / (SrcSize + DstSize)) /
|
unsigned NewUses = SrcUses + DstUses;
|
||||||
NewRCCount;
|
unsigned NewSize = SrcSize + DstSize;
|
||||||
if (SrcRC != NewRC && SrcSize > NewRCCount) {
|
if (SrcRC != NewRC && SrcSize > NewRCCount) {
|
||||||
unsigned SrcRCCount = allocatableRCRegs_[SrcRC].count();
|
unsigned SrcRCCount = allocatableRCRegs_[SrcRC].count();
|
||||||
float Density = ((float)SrcUses / SrcSize) / SrcRCCount;
|
if (NewUses*SrcSize*SrcRCCount > 2*SrcUses*NewSize*NewRCCount)
|
||||||
if (NewDensity > Density * 2.0f)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (DstRC != NewRC && DstSize > NewRCCount) {
|
if (DstRC != NewRC && DstSize > NewRCCount) {
|
||||||
unsigned DstRCCount = allocatableRCRegs_[DstRC].count();
|
unsigned DstRCCount = allocatableRCRegs_[DstRC].count();
|
||||||
float Density = ((float)DstUses / DstSize) / DstRCCount;
|
if (NewUses*DstSize*DstRCCount > 2*DstUses*NewSize*NewRCCount)
|
||||||
if (NewDensity > Density * 2.0f)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1669,10 +1665,9 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
|
|||||||
const TargetRegisterClass *RC = mri_->getRegClass(JoinVReg);
|
const TargetRegisterClass *RC = mri_->getRegClass(JoinVReg);
|
||||||
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
|
||||||
unsigned Length = li_->getApproximateInstructionCount(JoinVInt);
|
unsigned Length = li_->getApproximateInstructionCount(JoinVInt);
|
||||||
float Ratio = 1.0 / Threshold;
|
|
||||||
if (Length > Threshold &&
|
if (Length > Threshold &&
|
||||||
(((float)std::distance(mri_->use_nodbg_begin(JoinVReg),
|
std::distance(mri_->use_nodbg_begin(JoinVReg),
|
||||||
mri_->use_nodbg_end()) / Length) < Ratio)) {
|
mri_->use_nodbg_end()) * Threshold < Length) {
|
||||||
// Before giving up coalescing, if definition of source is defined by
|
// Before giving up coalescing, if definition of source is defined by
|
||||||
// trivial computation, try rematerializing it.
|
// trivial computation, try rematerializing it.
|
||||||
if (ReMaterializeTrivialDef(SrcInt, DstReg, DstSubIdx, CopyMI))
|
if (ReMaterializeTrivialDef(SrcInt, DstReg, DstSubIdx, CopyMI))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user