From 4ba8cfc5a4e98dbe55529bb2a0de17565e90c128 Mon Sep 17 00:00:00 2001 From: Wojciech Matyjewicz Date: Thu, 13 Dec 2007 16:22:58 +0000 Subject: [PATCH] Make these loops follow GetGEPOperands() behavior. Let: %q = GEP %p, X, ... If %p is a GEP, we can chase baseptr further, only if X==0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44999 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BasicAliasAnalysis.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 557d521546c..7ce9d1651f7 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -391,17 +391,19 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, if (isGEP(V1) && isGEP(V2)) { // Drill down into the first non-gep value, to test for must-aliasing of // the base pointers. - const Value *BasePtr1 = V1, *BasePtr2 = V2; - do { - BasePtr1 = cast(BasePtr1)->getOperand(0); - } while (isGEP(BasePtr1) && - cast(BasePtr1)->getOperand(1) == - Constant::getNullValue(cast(BasePtr1)->getOperand(1)->getType())); - do { - BasePtr2 = cast(BasePtr2)->getOperand(0); - } while (isGEP(BasePtr2) && - cast(BasePtr2)->getOperand(1) == - Constant::getNullValue(cast(BasePtr2)->getOperand(1)->getType())); + const User *G = cast(V1); + while (isGEP(G->getOperand(0)) && + G->getOperand(1) == + Constant::getNullValue(G->getOperand(1)->getType())) + G = cast(G->getOperand(0)); + const Value *BasePtr1 = G->getOperand(0); + + G = cast(V2); + while (isGEP(G->getOperand(0)) && + G->getOperand(1) == + Constant::getNullValue(G->getOperand(1)->getType())) + G = cast(G->getOperand(0)); + const Value *BasePtr2 = G->getOperand(0); // Do the base pointers alias? AliasResult BaseAlias = alias(BasePtr1, ~0U, BasePtr2, ~0U); -- 2.34.1