diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-08-04 20:51:05 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-08-04 20:51:05 +0000 |
commit | b4a96858722982655ad047e9be4d66636cf788a1 (patch) | |
tree | cc6d23f47809ff7524ae80698255ddb7a977d44b /llvm/lib | |
parent | 1a1c3ed56dbadc362904cd6d5500bc9d60bb8e7a (diff) | |
download | bcm5719-llvm-b4a96858722982655ad047e9be4d66636cf788a1.tar.gz bcm5719-llvm-b4a96858722982655ad047e9be4d66636cf788a1.zip |
Bug fix in SetOperandsForMemInstr: handle leading zeros correctly
when folding or not folding GEPs.
llvm-svn: 3245
Diffstat (limited to 'llvm/lib')
-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 b9dcd6deb16..1b27d32583c 100644 --- a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp +++ b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp @@ -995,18 +995,22 @@ SetOperandsForMemInstr(vector<MachineInstr*>& mvec, // If we have only constant indices, fold chains of constant indices // in this and any preceding GetElemPtr instructions. + bool foldedGEPs = false; if (allConstantIndices && (ptrChild->getOpLabel() == Instruction::GetElementPtr || ptrChild->getOpLabel() == GetElemPtrIdx)) - if (Value* newPtr = FoldGetElemChain((InstructionNode*) ptrChild, idxVec)) + if (Value* newPtr = FoldGetElemChain((InstructionNode*) ptrChild, idxVec)) { ptrVal = newPtr; + foldedGEPs = true; + } // Append the index vector of the current instruction, if any. - // Discard any leading [0] index. - if (memInst->getNumIndices() > 0) + // Skip the leading [0] index if preceding GEPs were folded into this. + if (memInst->getNumIndices() > 0) { + assert((!foldedGEPs || IsZero(*memInst->idx_begin())) && "1st index not 0"); idxVec.insert(idxVec.end(), - memInst->idx_begin() + IsZero(*memInst->idx_begin()), - memInst->idx_end()); + memInst->idx_begin() + foldedGEPs, memInst->idx_end()); + } // Now create the appropriate operands for the machine instruction SetMemOperands_Internal(mvec, mvecI, vmInstrNode, |