diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-09-09 14:54:21 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-09-09 14:54:21 +0000 |
commit | d50fb11d18a1967eb876e1d221ad0b0cde8b1836 (patch) | |
tree | fd059c3ec3e999a377ca0606fa1f44deb5c18d0b /llvm/lib/Target/Sparc | |
parent | e40840b26bf26cb488ac7ff118a486ce3711314f (diff) | |
download | bcm5719-llvm-d50fb11d18a1967eb876e1d221ad0b0cde8b1836.tar.gz bcm5719-llvm-d50fb11d18a1967eb876e1d221ad0b0cde8b1836.zip |
Silly bug fix: Machine code vector could be empty for a no-op cast instruction,
e.g., cast double to double.
llvm-svn: 3633
Diffstat (limited to 'llvm/lib/Target/Sparc')
-rw-r--r-- | llvm/lib/Target/Sparc/SparcInstrSelection.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp index 368afbb4ec9..6c5caaf6bff 100644 --- a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp +++ b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp @@ -1555,19 +1555,23 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, 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(); |