diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-08-24 14:43:33 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-08-24 14:43:33 +0000 |
commit | 5d67d8916e711daf4dd961d27f49ed408938be7c (patch) | |
tree | e645a2b59d6074b3fecd90ed908048475f96d4eb /llvm/lib/Transforms/Utils | |
parent | 38aa1636114391ad777909a7d9b9163b5cb047e5 (diff) | |
download | bcm5719-llvm-5d67d8916e711daf4dd961d27f49ed408938be7c.tar.gz bcm5719-llvm-5d67d8916e711daf4dd961d27f49ed408938be7c.zip |
[BypassSlowDivision] move map helper code to header; NFC
We can reuse this code with other div/rem transforms as shown in:
https://reviews.llvm.org/D31037
https://bugs.llvm.org/show_bug.cgi?id=31028
llvm-svn: 311661
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp index 83ec7f55d1a..d6c31f282e8 100644 --- a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -30,15 +30,6 @@ using namespace llvm; #define DEBUG_TYPE "bypass-slow-division" namespace { - struct DivOpInfo { - bool SignedOp; - Value *Dividend; - Value *Divisor; - - DivOpInfo(bool InSignedOp, Value *InDividend, Value *InDivisor) - : SignedOp(InSignedOp), Dividend(InDividend), Divisor(InDivisor) {} - }; - struct QuotRemPair { Value *Quotient; Value *Remainder; @@ -58,30 +49,7 @@ namespace { } namespace llvm { - template<> - struct DenseMapInfo<DivOpInfo> { - static bool isEqual(const DivOpInfo &Val1, const DivOpInfo &Val2) { - return Val1.SignedOp == Val2.SignedOp && - Val1.Dividend == Val2.Dividend && - Val1.Divisor == Val2.Divisor; - } - - static DivOpInfo getEmptyKey() { - return DivOpInfo(false, nullptr, nullptr); - } - - static DivOpInfo getTombstoneKey() { - return DivOpInfo(true, nullptr, nullptr); - } - - static unsigned getHashValue(const DivOpInfo &Val) { - return (unsigned)(reinterpret_cast<uintptr_t>(Val.Dividend) ^ - reinterpret_cast<uintptr_t>(Val.Divisor)) ^ - (unsigned)Val.SignedOp; - } - }; - - typedef DenseMap<DivOpInfo, QuotRemPair> DivCacheTy; + typedef DenseMap<DivRemMapKey, QuotRemPair> DivCacheTy; typedef DenseMap<unsigned, unsigned> BypassWidthsTy; typedef SmallPtrSet<Instruction *, 4> VisitedSetTy; } @@ -175,7 +143,7 @@ Value *FastDivInsertionTask::getReplacement(DivCacheTy &Cache) { // Then, look for a value in Cache. Value *Dividend = SlowDivOrRem->getOperand(0); Value *Divisor = SlowDivOrRem->getOperand(1); - DivOpInfo Key(isSignedOp(), Dividend, Divisor); + DivRemMapKey Key(isSignedOp(), Dividend, Divisor); auto CacheI = Cache.find(Key); if (CacheI == Cache.end()) { |