From 8d662b59f075da67e663ed142ecdd58e381eee98 Mon Sep 17 00:00:00 2001 From: Preston Gurd Date: Thu, 4 Oct 2012 21:33:40 +0000 Subject: This patch corrects commit 165126 by using an integer bit width instead of a pointer to a type, in order to remove the uses of getGlobalContext(). Patch by Tyler Nowicki. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165255 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/CodeGenPrepare.cpp | 5 +++-- lib/Transforms/Utils/BypassSlowDivision.cpp | 17 ++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/Transforms') diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index a2427cffbd..6d0186f9b4 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -154,9 +154,10 @@ bool CodeGenPrepare::runOnFunction(Function &F) { /// This optimization identifies DIV instructions that can be /// profitably bypassed and carried out with a shorter, faster divide. if (TLI && TLI->isSlowDivBypassed()) { - const DenseMap &BypassTypeMap = TLI->getBypassSlowDivTypes(); + const DenseMap &BypassWidths = + TLI->getBypassSlowDivWidths(); for (Function::iterator I = F.begin(); I != F.end(); I++) - EverMadeChange |= bypassSlowDivision(F, I, BypassTypeMap); + EverMadeChange |= bypassSlowDivision(F, I, BypassWidths); } // Eliminate blocks that contain only PHI nodes and an diff --git a/lib/Transforms/Utils/BypassSlowDivision.cpp b/lib/Transforms/Utils/BypassSlowDivision.cpp index 821b588112..bee2f7bcb6 100644 --- a/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -221,7 +221,7 @@ static bool reuseOrInsertFastDiv(Function &F, // be profitably bypassed and carried out with a shorter, faster divide. bool llvm::bypassSlowDivision(Function &F, Function::iterator &I, - const DenseMap &BypassTypeMap) { + const DenseMap &BypassWidths) { DivCacheTy DivCache; bool MadeChange = false; @@ -242,18 +242,17 @@ bool llvm::bypassSlowDivision(Function &F, if (!J->getType()->isIntegerTy()) continue; - // Get same type in global context + // Get bitwidth of div/rem instruction IntegerType *T = cast(J->getType()); - IntegerType *GT = IntegerType::get(getGlobalContext(), T->getBitWidth()); + int bitwidth = T->getBitWidth(); - // Continue if div/rem type is not bypassed - DenseMap::const_iterator BI = BypassTypeMap.find(GT); - if (BI == BypassTypeMap.end()) + // Continue if bitwidth is not bypassed + DenseMap::const_iterator BI = BypassWidths.find(bitwidth); + if (BI == BypassWidths.end()) continue; - // Get the bypass type in the original context - IntegerType *GBT = cast(BI->second); - IntegerType *BT = IntegerType::get(J->getContext(), GBT->getBitWidth()); + // Get type for div/rem instruction with bypass bitwidth + IntegerType *BT = IntegerType::get(J->getContext(), BI->second); MadeChange |= reuseOrInsertFastDiv(F, I, J, BT, UseDivOp, UseSignedOp, DivCache); -- cgit v1.2.3-70-g09d2