aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-23 07:42:19 +0000
committerChris Lattner <sabre@nondot.org>2004-02-23 07:42:19 +0000
commitfbc39d50455f1895117fe9796294942759026540 (patch)
tree1f4a118c663d8cbdff27e344e17ed8957bf3e9e9 /lib
parent65cf42d32f5f8127d56acc4040629a27a8709721 (diff)
Simplify code a bit, don't go off the end of the block, now that the current
block we are in might be empty git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/InstSelectSimple.cpp20
-rw-r--r--lib/Target/X86/X86ISelSimple.cpp20
2 files changed, 18 insertions, 22 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp
index 60d54b862d..2675a04ccf 100644
--- a/lib/Target/X86/InstSelectSimple.cpp
+++ b/lib/Target/X86/InstSelectSimple.cpp
@@ -682,7 +682,6 @@ void ISel::InsertFPRegKills() {
const TargetInstrInfo &TII = TM.getInstrInfo();
for (MachineFunction::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
- bool UsesFPReg = false;
for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (I->getOperand(i).isRegister()) {
@@ -695,16 +694,15 @@ void ISel::InsertFPRegKills() {
// 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;
- }
+ 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;
}
+ }
continue;
UsesFPReg:
// Okay, this block uses an FP register. If the block has successors (ie,
@@ -714,7 +712,7 @@ void ISel::InsertFPRegKills() {
// Rewind past any terminator instructions that might exist.
MachineBasicBlock::iterator I = BB->end();
while (I != BB->begin() && TII.isTerminatorInstr((--I)->getOpcode()));
- ++I;
+ if (I != BB->end()) ++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 60d54b862d..2675a04ccf 100644
--- a/lib/Target/X86/X86ISelSimple.cpp
+++ b/lib/Target/X86/X86ISelSimple.cpp
@@ -682,7 +682,6 @@ void ISel::InsertFPRegKills() {
const TargetInstrInfo &TII = TM.getInstrInfo();
for (MachineFunction::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
- bool UsesFPReg = false;
for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (I->getOperand(i).isRegister()) {
@@ -695,16 +694,15 @@ void ISel::InsertFPRegKills() {
// 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;
- }
+ 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;
}
+ }
continue;
UsesFPReg:
// Okay, this block uses an FP register. If the block has successors (ie,
@@ -714,7 +712,7 @@ void ISel::InsertFPRegKills() {
// Rewind past any terminator instructions that might exist.
MachineBasicBlock::iterator I = BB->end();
while (I != BB->begin() && TII.isTerminatorInstr((--I)->getOpcode()));
- ++I;
+ if (I != BB->end()) ++I;
BMI(BB, I, X86::FP_REG_KILL, 0);
++NumFPKill;
}