Fix some warnings, some of which were spurious, and some of which were real
[oota-llvm.git] / lib / Target / X86 / FloatingPoint.cpp
index 53f6ec0feb45c5478793248e28795adeb152ace4..57556827678fd1f57fcf95e11d47f9107db62c9a 100644 (file)
@@ -42,6 +42,7 @@
 #include "Support/Debug.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/Statistic.h"
+#include "Support/STLExtras.h"
 #include <algorithm>
 #include <set>
 using namespace llvm;
@@ -199,11 +200,8 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) {
       continue;  // Efficiently ignore non-fp insts!
 
     MachineInstr *PrevMI = 0;
-    if (I != BB.begin()) {
-        MachineBasicBlock::iterator tmp = I;
-        --tmp;
-        PrevMI = tmp;
-    }
+    if (I != BB.begin())
+        PrevMI = prior(I);
 
     ++NumFP;  // Keep track of # of pseudo instrs
     DEBUG(std::cerr << "\nFPInst:\t";
@@ -247,20 +245,20 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) {
     }
     
     // Print out all of the instructions expanded to if -debug
-    DEBUG(if (&*I == PrevMI) {
-            std::cerr<< "Just deleted pseudo instruction\n";
-          } else {
-           MachineBasicBlock::iterator Start = I;
-           // Rewind to first instruction newly inserted.
-           while (Start != BB.begin() &&
-                   --Start != MachineBasicBlock::iterator(PrevMI));
-            ++Start;
-           std::cerr << "Inserted instructions:\n\t";
-           Start->print(std::cerr, MF.getTarget());
-           while (++Start != I); ++Start;
-         }
-         dumpStack();
-         );
+    DEBUG(
+      MachineBasicBlock::iterator PrevI(PrevMI);
+      if (I == PrevI) {
+        std::cerr<< "Just deleted pseudo instruction\n";
+      } else {
+        MachineBasicBlock::iterator Start = I;
+        // Rewind to first instruction newly inserted.
+        while (Start != BB.begin() && prior(Start) != PrevI) --Start;
+        std::cerr << "Inserted instructions:\n\t";
+        Start->print(std::cerr, MF.getTarget());
+        while (++Start != next(I));
+      }
+      dumpStack();
+    );
 
     Changed = true;
   }