summaryrefslogtreecommitdiffhomepage
path: root/ir/adt
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2015-01-25 00:38:52 +0100
committerChristoph Mallon <mallon@cs.uni-saarland.de>2015-01-25 10:46:04 +0100
commit64790ad734834b052185c48479b846560fff9686 (patch)
tree0c75331fe571208ed3156a153c15fe51ee085779 /ir/adt
parent8aa9e4d9e6308418f82ee18f8a11e501425497fe (diff)
bitfiddle: Remove the unused function add_saturated().
Diffstat (limited to 'ir/adt')
-rw-r--r--ir/adt/bitfiddle.h32
1 files changed, 0 insertions, 32 deletions
diff --git a/ir/adt/bitfiddle.h b/ir/adt/bitfiddle.h
index ef326bc..7879f0d 100644
--- a/ir/adt/bitfiddle.h
+++ b/ir/adt/bitfiddle.h
@@ -20,38 +20,6 @@
#include "compiler.h"
/**
- * Add saturated.
- * @param x Summand 1.
- * @param y Summand 2.
- * @return x + y or INT_MAX/INT_MIN if an overflow occurred and x,y was
- * positive/negative.
- *
- * @note See hacker's delight, page 27.
- */
-static inline int add_saturated(int x, int y)
-{
- int sum = x + y;
- /*
- An overflow occurs, if the sign of the both summands is equal
- and the one of the sum is different from the summand's one.
- The sign bit is 1, if an overflow occurred, 0 otherwise.
- int overflow = ~(x ^ y) & (sum ^ x);
- */
- int overflow = (x ^ sum) & (y ^ sum);
-
- /*
- The infinity to use.
- Make a mask of the sign bit of x and y (they are the same if an
- overflow occurred).
- INT_MIN == ~INT_MAX, so if the sign was negative, INT_MAX becomes
- INT_MIN.
- */
- int inf = (x >> (sizeof(x) * 8 - 1)) ^ INT_MAX;
-
- return overflow < 0 ? inf : sum;
-}
-
-/**
* Compute the count of set bits in a 32-bit word.
* @param x A 32-bit word.
* @return The number of bits set in x.