summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-14 17:09:46 +0000
committerChris Lattner <sabre@nondot.org>2003-11-14 17:09:46 +0000
commitab6895ea76cb56b96e33fedeeddfa9245598d066 (patch)
treed7e5ad1df576eca4681081918fa6c37d98cefb07 /llvm/lib/Analysis/DataStructure/Local.cpp
parent93dea78f850b4a12bb27a161e2f9ef82278ed7bb (diff)
downloadbcm5719-llvm-ab6895ea76cb56b96e33fedeeddfa9245598d066.tar.gz
bcm5719-llvm-ab6895ea76cb56b96e33fedeeddfa9245598d066.zip
Implement a small optimization to handling of GEP's that are equivalent to casts.
This results in substantially reduced collapsing for some testcases llvm-svn: 10002
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/Local.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/Local.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp
index 79f392078a1..a7cf854c47e 100644
--- a/llvm/lib/Analysis/DataStructure/Local.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud