From 47b71c5844fdfc55c159db290cd32ebb3526426b 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! llvm-svn: 73299 --- llvm/lib/Transforms/IPO/MergeFunctions.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 1dd3279b9eb..5693cc0fc3b 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/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