[llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.h X86InstrInfo.cpp

Dale Johannesen dalej at apple.com
Thu Jun 14 15:04:08 PDT 2007



Changes in directory llvm/lib/Target/X86:

X86InstrInfo.h updated: 1.65 -> 1.66
X86InstrInfo.cpp updated: 1.90 -> 1.91
---
Log message:

Do not treat FP_REG_KILL as terminator in branch analysis (X86).


---
Diffs of the changes:  (+11 -4)

 X86InstrInfo.cpp |   14 ++++++++++----
 X86InstrInfo.h   |    1 +
 2 files changed, 11 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/X86/X86InstrInfo.h
diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.65 llvm/lib/Target/X86/X86InstrInfo.h:1.66
--- llvm/lib/Target/X86/X86InstrInfo.h:1.65	Thu Jun 14 15:50:44 2007
+++ llvm/lib/Target/X86/X86InstrInfo.h	Thu Jun 14 17:03:45 2007
@@ -261,6 +261,7 @@
   virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
 
   // Branch analysis.
+  virtual bool isUnpredicatedTerminator(const MachineInstr* MI) const;
   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
                              MachineBasicBlock *&FBB,
                              std::vector<MachineOperand> &Cond) const;


Index: llvm/lib/Target/X86/X86InstrInfo.cpp
diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.90 llvm/lib/Target/X86/X86InstrInfo.cpp:1.91
--- llvm/lib/Target/X86/X86InstrInfo.cpp:1.90	Thu Jun 14 15:50:44 2007
+++ llvm/lib/Target/X86/X86InstrInfo.cpp	Thu Jun 14 17:03:45 2007
@@ -398,13 +398,20 @@
   }
 }
 
+// For purposes of branch analysis do not count FP_REG_KILL as a terminator.
+bool X86InstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
+  const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
+  if (MI->getOpcode() == X86::FP_REG_KILL)
+    return false;
+  if (TID->Flags & M_TERMINATOR_FLAG)
+    return !isPredicated(MI);
+  return false;
+}
 
 bool X86InstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, 
                                  MachineBasicBlock *&TBB,
                                  MachineBasicBlock *&FBB,
                                  std::vector<MachineOperand> &Cond) const {
-  // TODO: If FP_REG_KILL is around, ignore it.
-                                   
   // If the block has no terminators, it just falls into the block after it.
   MachineBasicBlock::iterator I = MBB.end();
   if (I == MBB.begin() || !isUnpredicatedTerminator(--I))
@@ -439,8 +446,7 @@
   MachineInstr *SecondLastInst = I;
   
   // If there are three terminators, we don't know what sort of block this is.
-  if (SecondLastInst && I != MBB.begin() &&
-      isTerminatorInstr((--I)->getOpcode()))
+  if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(--I))
     return true;
 
   // If the block ends with X86::JMP and a conditional branch, handle it.






More information about the llvm-commits mailing list