Support fp64 immediate zero, this fixes only part of PR5445

because the testcase is triggering one more bug.

llvm-svn: 88674
This commit is contained in:
Bruno Cardoso Lopes 2009-11-13 18:49:59 +00:00
parent 9f2ee2bb26
commit a03b5b44fc
2 changed files with 22 additions and 3 deletions

View File

@ -314,6 +314,16 @@ SDNode* MipsDAGToDAGISel::Select(SDValue N) {
case ISD::GLOBAL_OFFSET_TABLE:
return getGlobalBaseReg();
case ISD::ConstantFP: {
ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(N);
if (N.getValueType() == MVT::f64 && CN->isExactlyValue(+0.0)) {
SDValue Zero = CurDAG->getRegister(Mips::ZERO, MVT::i32);
ReplaceUses(N, Zero);
return Zero.getNode();
}
break;
}
/// Handle direct and indirect calls when using PIC. On PIC, when
/// GOT is smaller than about 64k (small code) the GA target is
/// loaded with only one instruction. Otherwise GA's target must

View File

@ -134,6 +134,9 @@ copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
const TargetRegisterClass *DestRC,
const TargetRegisterClass *SrcRC) const {
DebugLoc DL = DebugLoc::getUnknownLoc();
const MachineFunction *MF = MBB.getParent();
const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo();
if (I != MBB.end()) DL = I->getDebugLoc();
if (DestRC != SrcRC) {
@ -153,6 +156,13 @@ copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
else if ((DestRC == Mips::FGR32RegisterClass) &&
(SrcRC == Mips::CPURegsRegisterClass))
BuildMI(MBB, I, DL, get(Mips::MTC1), DestReg).addReg(SrcReg);
else if ((DestRC == Mips::AFGR64RegisterClass) &&
(SrcRC == Mips::CPURegsRegisterClass) &&
(SrcReg == Mips::ZERO)) {
const unsigned *AliasSet = TRI->getAliasSet(DestReg);
BuildMI(MBB, I, DL, get(Mips::MTC1), AliasSet[0]).addReg(SrcReg);
BuildMI(MBB, I, DL, get(Mips::MTC1), AliasSet[1]).addReg(SrcReg);
}
// Move from/to Hi/Lo registers
else if ((DestRC == Mips::HILORegisterClass) &&
@ -163,9 +173,8 @@ copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
(DestRC == Mips::CPURegsRegisterClass)) {
unsigned Opc = (SrcReg == Mips::HI) ? Mips::MFHI : Mips::MFLO;
BuildMI(MBB, I, DL, get(Opc), DestReg);
// Can't copy this register
} else
} else
// Can't copy this register
return false;
return true;