diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-06-23 17:47:40 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-06-23 17:47:40 +0000 |
| commit | 0067ff4678ca8934c06eeb7f6c4dc0f2c8bf62f6 (patch) | |
| tree | c62b2181a9edb94a8c9a67ac0e9816d4df30ad19 /llvm/lib/Support | |
| parent | f7062b23137f3fda28c6edbfbe1b3668af00b0c2 (diff) | |
| download | bcm5719-llvm-0067ff4678ca8934c06eeb7f6c4dc0f2c8bf62f6.tar.gz bcm5719-llvm-0067ff4678ca8934c06eeb7f6c4dc0f2c8bf62f6.zip | |
Support: Extract ScaledNumbers::compare()
llvm-svn: 211507
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/ScaledNumber.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Support/ScaledNumber.cpp b/llvm/lib/Support/ScaledNumber.cpp index e7531744b67..10b23273d0f 100644 --- a/llvm/lib/Support/ScaledNumber.cpp +++ b/llvm/lib/Support/ScaledNumber.cpp @@ -117,3 +117,16 @@ std::pair<uint64_t, int16_t> ScaledNumbers::divide64(uint64_t Dividend, return getRounded(Quotient, Shift, Dividend >= getHalf(Divisor)); } + +int ScaledNumbers::compareImpl(uint64_t L, uint64_t R, int ScaleDiff) { + assert(ScaleDiff >= 0 && "wrong argument order"); + assert(ScaleDiff < 64 && "numbers too far apart"); + + uint64_t L_adjusted = L >> ScaleDiff; + if (L_adjusted < R) + return -1; + if (L_adjusted > R) + return 1; + + return L > L_adjusted << ScaleDiff ? 1 : 0; +} |

