diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-14 17:09:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-14 17:09:46 +0000 |
commit | 179bc7dcb16772a68d46776e44d8879856524151 (patch) | |
tree | d59965b2d9d4478512175ae3a05ca4339813cf13 /lib/Analysis/DataStructure/Local.cpp | |
parent | db9546e3248024fe427db6becdd96053e9dd3452 (diff) |
Implement a small optimization to handling of GEP's that are equivalent to casts.
This results in substantially reduced collapsing for some testcases
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Local.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/Local.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 79f392078a..a7cf854c47 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -308,6 +308,24 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) { DSNodeHandle Value = getValueDest(*GEP.getOperand(0)); if (Value.getNode() == 0) return; + // As a special case, if all of the index operands of GEP are constant zeros, + // handle this just like we handle casts (ie, don't do much). + bool AllZeros = true; + for (unsigned i = 1, e = GEP.getNumOperands(); i != e; ++i) + if (GEP.getOperand(i) != + Constant::getNullValue(GEP.getOperand(i)->getType())) { + AllZeros = false; + break; + } + + // If all of the indices are zero, the result points to the operand without + // applying the type. + if (AllZeros) { + setDestTo(GEP, Value); + return; + } + + const PointerType *PTy = cast<PointerType>(GEP.getOperand(0)->getType()); const Type *CurTy = PTy->getElementType(); |