diff options
| author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-10 01:05:26 +0000 |
|---|---|---|
| committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-10 01:05:26 +0000 |
| commit | 209d8e1c3be152b7a45e6a78d25de58e924ddf8a (patch) | |
| tree | c39f5d3d6c99a351af076e9a9ace59d7ff906b9e /llvm/lib/Target/Sparc | |
| parent | 1812fc499d7dc8bb7130c94cc2388fce88786b06 (diff) | |
| download | bcm5719-llvm-209d8e1c3be152b7a45e6a78d25de58e924ddf8a.tar.gz bcm5719-llvm-209d8e1c3be152b7a45e6a78d25de58e924ddf8a.zip | |
Must generate an instruction for GetElementPtr if single user is not
a memory instruction!
llvm-svn: 1238
Diffstat (limited to 'llvm/lib/Target/Sparc')
| -rw-r--r-- | llvm/lib/Target/Sparc/SparcInstrSelection.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp index 25299171b8c..cd017b6eb27 100644 --- a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp +++ b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp @@ -1819,16 +1819,26 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, case 56: // reg: GetElemPtrIdx(reg,reg) if (subtreeRoot->parent() != NULL) { - // Check if the parent was an array access. - // If so, we still need to generate this instruction. - MemAccessInst* memInst = (MemAccessInst*) - subtreeRoot->getInstruction(); - const PointerType* ptrType = - (const PointerType*) memInst->getPtrOperand()->getType(); - if (! ptrType->getValueType()->isArrayType()) - {// we don't need a separate instr - numInstr = 0; // don't forward operand! - break; + // If the parent was a memory operation and not an array access, + // the parent will fold this instruction in so generate nothing. + // + Instruction* parent = + cast<Instruction>(subtreeRoot->parent()->getValue()); + if (parent->getOpcode() == Instruction::Load || + parent->getOpcode() == Instruction::Store || + parent->getOpcode() == Instruction::GetElementPtr) + { + // Check if the parent is an array access, + // If so, we still need to generate this instruction. + GetElementPtrInst* getElemInst = + cast<GetElementPtrInst>(subtreeRoot->getInstruction()); + const PointerType* ptrType = + (const PointerType*) getElemInst->getPtrOperand()->getType(); + if (! ptrType->getValueType()->isArrayType()) + {// we don't need a separate instr + numInstr = 0; // don't forward operand! + break; + } } } // else in all other cases we need to a separate ADD instruction |

