[llvm-commits] CVS: llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp

Vikram Adve vadve at cs.uiuc.edu
Fri Sep 27 09:28:01 PDT 2002


Changes in directory llvm/lib/CodeGen/PostOpts:

PeepholeOpts.cpp updated: 1.1 -> 1.2

---
Log message:

Bug fix: some redundant copies were not being deleted after detection :-|.


---
Diffs of the changes:

Index: llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp
diff -u llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.1 llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.2
--- llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.1	Thu Sep 19 19:42:10 2002
+++ llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp	Fri Sep 27 09:27:37 2002
@@ -1,4 +1,4 @@
-// $Id: PeepholeOpts.cpp,v 1.1 2002/09/20 00:42:10 vadve Exp $ -*-c++-*-
+// $Id: PeepholeOpts.cpp,v 1.2 2002/09/27 14:27:37 vadve Exp $ -*-c++-*-
 //***************************************************************************
 // File:
 //	PeepholeOpts.h
@@ -30,23 +30,25 @@
                   const TargetMachine& target)
 {
   // Check if this instruction is in a delay slot of its predecessor.
-  // If so, replace this instruction with a nop, else just delete it.
-  // By replacing in place, we save having to update the I-I maps.
   if (BBI != mvec.begin())
     {
       const MachineInstrInfo& mii = target.getInstrInfo();
       MachineInstr* predMI = *(BBI-1);
       if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode()))
         {
+          // This instruction is in a delay slot of its predecessor, so
+          // replace it with a nop. By replacing in place, we save having
+          // to update the I-I maps.
+          // 
           assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets");
           (*BBI)->replace(mii.getNOPOpCode(), 0);
+          return;
         }
     }
-  else
-    {
-      mvec.erase(BBI);
-      BBI = mvec.end();
-    }
+  
+  // The instruction is not in a delay slot, so we can simply erase it.
+  mvec.erase(BBI);
+  BBI = mvec.end();
 }
 
 //******************* Individual Peephole Optimizations ********************/





More information about the llvm-commits mailing list