summaryrefslogtreecommitdiff
path: root/include/llvm/Support/MathExtras.h
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-05-13 00:24:22 +0000
committerDale Johannesen <dalej@apple.com>2009-05-13 00:24:22 +0000
commit7b9486ad4355a010d22e0737cee9cd7c7b747ece (patch)
treeb7bfebbf35cc0ff04599b78130048ee6b8f163b9 /include/llvm/Support/MathExtras.h
parent0e0da734bbdfa1d3f55cd04db31d83b97e4556f7 (diff)
downloadllvm-7b9486ad4355a010d22e0737cee9cd7c7b747ece.tar.gz
llvm-7b9486ad4355a010d22e0737cee9cd7c7b747ece.tar.bz2
llvm-7b9486ad4355a010d22e0737cee9cd7c7b747ece.tar.xz
Add an int64_t variant of abs, for host environments
without one. Use it where we were using abs on int64_t objects. (I strongly suspect the casts to unsigned in the fragments in LoopStrengthReduce are not doing whatever the original intent was, but the obvious change to uint64_t doesn't work. Maybe later.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71612 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r--include/llvm/Support/MathExtras.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 0fb2760b12..fd3ac9157b 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -425,6 +425,13 @@ inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
return ((Value + Align - 1) / Align) * Align;
}
+/// abs64 - absolute value of a 64-bit int. Not all environments support
+/// "abs" on whatever their name for the 64-bit int type is. The absolute
+/// value of the largest negative number is undefined, as with "abs".
+inline int64_t abs64(int64_t x) {
+ return (x < 0) ? -x : x;
+}
+
} // End llvm namespace
#endif