[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp

Vikram Adve vadve at cs.uiuc.edu
Mon Sep 9 09:55:01 PDT 2002


Changes in directory llvm/lib/Target/Sparc:

SparcInstrSelection.cpp updated: 1.69 -> 1.70

---
Log message:

Silly bug fix: Machine code vector could be empty for a no-op cast instruction,
e.g., cast double to double.


---
Diffs of the changes:

Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.69 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.70
--- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.69	Thu Sep  5 13:32:13 2002
+++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp	Mon Sep  9 09:54:21 2002
@@ -1555,19 +1555,23 @@
       case  31:	// reg:   ToFloatTy(reg):
       case  32:	// reg:   ToDoubleTy(reg):
       case 232:	// reg:   ToDoubleTy(Constant):
-
+      
         // If this instruction has a parent (a user) in the tree 
         // and the user is translated as an FsMULd instruction,
         // then the cast is unnecessary.  So check that first.
         // In the future, we'll want to do the same for the FdMULq instruction,
         // so do the check here instead of only for ToFloatTy(reg).
         // 
-        if (subtreeRoot->parent() != NULL &&
-            MachineCodeForInstruction::get(((InstructionNode*)subtreeRoot->parent())->getInstruction())[0]->getOpCode() == FSMULD)
+        if (subtreeRoot->parent() != NULL)
           {
-            forwardOperandNum = 0;          // forward first operand to user
+            const MachineCodeForInstruction& mcfi =
+              MachineCodeForInstruction::get(
+                cast<InstructionNode>(subtreeRoot->parent())->getInstruction());
+            if (mcfi.size() == 0 || mcfi.front()->getOpCode() == FSMULD)
+              forwardOperandNum = 0;    // forward first operand to user
           }
-        else
+
+        if (forwardOperandNum != 0)     // we do need the cast
           {
             Value* leftVal = subtreeRoot->leftChild()->getValue();
             const Type* opType = leftVal->getType();





More information about the llvm-commits mailing list