diff options
author | Preston Gurd <preston.gurd@intel.com> | 2012-10-04 21:33:40 +0000 |
---|---|---|
committer | Preston Gurd <preston.gurd@intel.com> | 2012-10-04 21:33:40 +0000 |
commit | 0d67f5106c51cb0f72437336449dc46100254a85 (patch) | |
tree | 134970ab6b621d4628fcaa4b7a7013f8c320b460 /llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | |
parent | 330840ffd920c1e9f58561a227c0b3dbe86650da (diff) | |
download | bcm5719-llvm-0d67f5106c51cb0f72437336449dc46100254a85.tar.gz bcm5719-llvm-0d67f5106c51cb0f72437336449dc46100254a85.zip |
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.
llvm-svn: 165255
Diffstat (limited to 'llvm/lib/Transforms/Utils/BypassSlowDivision.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp index 821b588112d..bee2f7bcb6e 100644 --- a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/llvm/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<Type*, Type*> &BypassTypeMap) { + const DenseMap<unsigned int, unsigned int> &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<IntegerType>(J->getType()); - IntegerType *GT = IntegerType::get(getGlobalContext(), T->getBitWidth()); + int bitwidth = T->getBitWidth(); - // Continue if div/rem type is not bypassed - DenseMap<Type *, Type *>::const_iterator BI = BypassTypeMap.find(GT); - if (BI == BypassTypeMap.end()) + // Continue if bitwidth is not bypassed + DenseMap<unsigned int, unsigned int>::const_iterator BI = BypassWidths.find(bitwidth); + if (BI == BypassWidths.end()) continue; - // Get the bypass type in the original context - IntegerType *GBT = cast<IntegerType>(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); |