From a142c9302b690cda799737d78ec29414e3b47fc8 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sat, 13 Jun 2009 19:09:52 +0000 Subject: Unlike the other instructions, GEP really does need to look at the type of a pointer. This fixes kimwitu++. Pointed out by Frits van Bommel on review! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73299 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/MergeFunctions.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp index 1dd3279b9e..5693cc0fc3 100644 --- a/lib/Transforms/IPO/MergeFunctions.cpp +++ b/lib/Transforms/IPO/MergeFunctions.cpp @@ -284,6 +284,20 @@ static bool equals(const BasicBlock *BB1, const BasicBlock *BB2, if (!isEquivalentOperation(FI, GI)) return false; + if (isa(FI)) { + const GetElementPtrInst *GEPF = cast(FI); + const GetElementPtrInst *GEPG = cast(GI); + if (GEPF->hasAllZeroIndices() && GEPG->hasAllZeroIndices()) { + // It's effectively a bitcast. + ++FI, ++GI; + continue; + } + + // TODO: we only really care about the elements before the index + if (FI->getOperand(0)->getType() != GI->getOperand(0)->getType()) + return false; + } + if (ValueMap[FI] == GI) { ++FI, ++GI; continue; -- cgit v1.2.3