diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-23 07:29:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-23 07:29:45 +0000 |
commit | 65cf42d32f5f8127d56acc4040629a27a8709721 (patch) | |
tree | 116e420dbab8051e9b0346d3ea5c4a23d38fd0e0 | |
parent | c5943fb186fabacd8f1ab0d135a103caa0a226ef (diff) |
We were forgetting to add FP_REG_KILL instructions to basic blocks which will
eventually get an assignment due to elimination of PHIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11743 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/InstSelectSimple.cpp | 42 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelSimple.cpp | 42 |
2 files changed, 54 insertions, 30 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index a5277c0d2a..60d54b862d 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -688,23 +688,35 @@ void ISel::InsertFPRegKills() { if (I->getOperand(i).isRegister()) { unsigned Reg = I->getOperand(i).getReg(); if (MRegisterInfo::isVirtualRegister(Reg)) - if (RegMap.getRegClass(Reg)->getSize() == 10) { - UsesFPReg = true; - break; - } + if (RegMap.getRegClass(Reg)->getSize() == 10) + goto UsesFPReg; + } + + // If we haven't found an FP register use or def in this basic block, check + // to see if any of our successors has an FP PHI node, which will cause a + // copy to be inserted into this block. + if (!UsesFPReg) + for (succ_const_iterator SI = succ_begin(BB->getBasicBlock()), + E = succ_end(BB->getBasicBlock()); SI != E; ++SI) { + MachineBasicBlock *SBB = MBBMap[*SI]; + for (MachineBasicBlock::iterator I = SBB->begin(); + I != SBB->end() && I->getOpcode() == X86::PHI; ++I) { + if (RegMap.getRegClass(I->getOperand(0).getReg())->getSize() == 10) + goto UsesFPReg; } - if (UsesFPReg) { - // Okay, this block uses an FP register. If the block has successors (ie, - // it's not an unwind/return), insert the FP_REG_KILL instruction. - if (BB->getBasicBlock()->getTerminator()->getNumSuccessors() && - RequiresFPRegKill(BB->getBasicBlock())) { - // Rewind past any terminator instructions that might exist. - MachineBasicBlock::iterator I = BB->end(); - while (I != BB->begin() && TII.isTerminatorInstr((--I)->getOpcode())); - ++I; - BMI(BB, I, X86::FP_REG_KILL, 0); - ++NumFPKill; } + continue; + UsesFPReg: + // Okay, this block uses an FP register. If the block has successors (ie, + // it's not an unwind/return), insert the FP_REG_KILL instruction. + if (BB->getBasicBlock()->getTerminator()->getNumSuccessors() && + RequiresFPRegKill(BB->getBasicBlock())) { + // Rewind past any terminator instructions that might exist. + MachineBasicBlock::iterator I = BB->end(); + while (I != BB->begin() && TII.isTerminatorInstr((--I)->getOpcode())); + ++I; + BMI(BB, I, X86::FP_REG_KILL, 0); + ++NumFPKill; } } } diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index a5277c0d2a..60d54b862d 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -688,23 +688,35 @@ void ISel::InsertFPRegKills() { if (I->getOperand(i).isRegister()) { unsigned Reg = I->getOperand(i).getReg(); if (MRegisterInfo::isVirtualRegister(Reg)) - if (RegMap.getRegClass(Reg)->getSize() == 10) { - UsesFPReg = true; - break; - } + if (RegMap.getRegClass(Reg)->getSize() == 10) + goto UsesFPReg; + } + + // If we haven't found an FP register use or def in this basic block, check + // to see if any of our successors has an FP PHI node, which will cause a + // copy to be inserted into this block. + if (!UsesFPReg) + for (succ_const_iterator SI = succ_begin(BB->getBasicBlock()), + E = succ_end(BB->getBasicBlock()); SI != E; ++SI) { + MachineBasicBlock *SBB = MBBMap[*SI]; + for (MachineBasicBlock::iterator I = SBB->begin(); + I != SBB->end() && I->getOpcode() == X86::PHI; ++I) { + if (RegMap.getRegClass(I->getOperand(0).getReg())->getSize() == 10) + goto UsesFPReg; } - if (UsesFPReg) { - // Okay, this block uses an FP register. If the block has successors (ie, - // it's not an unwind/return), insert the FP_REG_KILL instruction. - if (BB->getBasicBlock()->getTerminator()->getNumSuccessors() && - RequiresFPRegKill(BB->getBasicBlock())) { - // Rewind past any terminator instructions that might exist. - MachineBasicBlock::iterator I = BB->end(); - while (I != BB->begin() && TII.isTerminatorInstr((--I)->getOpcode())); - ++I; - BMI(BB, I, X86::FP_REG_KILL, 0); - ++NumFPKill; } + continue; + UsesFPReg: + // Okay, this block uses an FP register. If the block has successors (ie, + // it's not an unwind/return), insert the FP_REG_KILL instruction. + if (BB->getBasicBlock()->getTerminator()->getNumSuccessors() && + RequiresFPRegKill(BB->getBasicBlock())) { + // Rewind past any terminator instructions that might exist. + MachineBasicBlock::iterator I = BB->end(); + while (I != BB->begin() && TII.isTerminatorInstr((--I)->getOpcode())); + ++I; + BMI(BB, I, X86::FP_REG_KILL, 0); + ++NumFPKill; } } } |