aboutsummaryrefslogtreecommitdiff
path: root/gcc/double-int.h
diff options
context:
space:
mode:
authorLawrence Crowl <crowl@google.com>2012-09-07 00:06:35 +0000
committerLawrence Crowl <crowl@gcc.gnu.org>2012-09-07 00:06:35 +0000
commit27bcd47cfab04b1b1e6d2712e34b9b289c7a2dd7 (patch)
tree82231821d6793cd33f15d6b9792a8b82f2ec15d1 /gcc/double-int.h
parent316b938ed79ef024177ab82057a061a7a4b5af67 (diff)
downloadgcc-27bcd47cfab04b1b1e6d2712e34b9b289c7a2dd7.zip
gcc-27bcd47cfab04b1b1e6d2712e34b9b289c7a2dd7.tar.gz
gcc-27bcd47cfab04b1b1e6d2712e34b9b289c7a2dd7.tar.bz2
Modify gcc/*.[hc] double_int call sites to use the new interface.
This change entailed adding a few new methods to double_int. The change results in a 0.163% time improvement with a 70% confidence. Tested on x86_64. Index: gcc/ChangeLog 2012-09-06 Lawrence Crowl <crowl@google.com> * double-int.h (double_int::operator &=): New. (double_int::operator ^=): New. (double_int::operator |=): New. (double_int::mul_with_sign): Modify overflow parameter to bool*. (double_int::add_with_sign): New. (double_int::ule): New. (double_int::sle): New. (binary double_int::operator *): Remove parameter name. (binary double_int::operator +): Likewise. (binary double_int::operator -): Likewise. (binary double_int::operator &): Likewise. (double_int::operator |): Likewise. (double_int::operator ^): Likewise. (double_int::and_not): Likewise. (double_int::from_shwi): Tidy formatting. (double_int::from_uhwi): Likewise. (double_int::from_uhwi): Likewise. * double-int.c (double_int::mul_with_sign): Modify overflow parameter to bool*. (double_int::add_with_sign): New. (double_int::ule): New. (double_int::sle): New. * builtins.c: Modify to use the new double_int interface. * cgraph.c: Likewise. * combine.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * fixed-value.c: Likewise. * fold-const.c: Likewise. * gimple-fold.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * gimplify-rtx.c: Likewise. * ipa-prop.c: Likewise. * loop-iv.c: Likewise. * optabs.c: Likewise. * stor-layout.c: Likewise. * tree-affine.c: Likewise. * tree-cfg.c: Likewise. * tree-dfa.c: Likewise. * tree-flow-inline.h: Likewise. * tree-object-size.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-sccvn: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vrp.c: Likewise. * tree.h: Likewise. * tree.c: Likewise. * varasm.c: Likewise. From-SVN: r191047
Diffstat (limited to 'gcc/double-int.h')
-rw-r--r--gcc/double-int.h60
1 files changed, 44 insertions, 16 deletions
diff --git a/gcc/double-int.h b/gcc/double-int.h
index 3d9aa2c..bc7aca1 100644
--- a/gcc/double-int.h
+++ b/gcc/double-int.h
@@ -50,9 +50,8 @@ along with GCC; see the file COPYING3. If not see
numbers with precision higher than HOST_WIDE_INT). It might be less
confusing to have them both signed or both unsigned. */
-typedef struct double_int
+struct double_int
{
-public:
/* Normally, we would define constructors to create instances.
Two things prevent us from doing so.
First, defining a constructor makes the class non-POD in C++03,
@@ -78,6 +77,9 @@ public:
double_int &operator *= (double_int);
double_int &operator += (double_int);
double_int &operator -= (double_int);
+ double_int &operator &= (double_int);
+ double_int &operator ^= (double_int);
+ double_int &operator |= (double_int);
/* The following functions are non-mutating operations. */
@@ -104,17 +106,18 @@ public:
/* Arithmetic operation functions. */
double_int set_bit (unsigned) const;
- double_int mul_with_sign (double_int, bool, int *) const;
+ double_int mul_with_sign (double_int, bool unsigned_p, bool *overflow) const;
+ double_int add_with_sign (double_int, bool unsigned_p, bool *overflow) const;
- double_int operator * (double_int b) const;
- double_int operator + (double_int b) const;
- double_int operator - (double_int b) const;
+ double_int operator * (double_int) const;
+ double_int operator + (double_int) const;
+ double_int operator - (double_int) const;
double_int operator - () const;
double_int operator ~ () const;
- double_int operator & (double_int b) const;
- double_int operator | (double_int b) const;
- double_int operator ^ (double_int b) const;
- double_int and_not (double_int b) const;
+ double_int operator & (double_int) const;
+ double_int operator | (double_int) const;
+ double_int operator ^ (double_int) const;
+ double_int and_not (double_int) const;
double_int lshift (HOST_WIDE_INT count, unsigned int prec, bool arith) const;
double_int rshift (HOST_WIDE_INT count, unsigned int prec, bool arith) const;
@@ -156,8 +159,10 @@ public:
int scmp (double_int b) const;
bool ult (double_int b) const;
+ bool ule (double_int b) const;
bool ugt (double_int b) const;
bool slt (double_int b) const;
+ bool sle (double_int b) const;
bool sgt (double_int b) const;
double_int max (double_int b, bool uns);
@@ -176,7 +181,7 @@ public:
unsigned HOST_WIDE_INT low;
HOST_WIDE_INT high;
-} double_int;
+};
#define HOST_BITS_PER_DOUBLE_INT (2 * HOST_BITS_PER_WIDE_INT)
@@ -185,8 +190,8 @@ public:
/* Constructs double_int from integer CST. The bits over the precision of
HOST_WIDE_INT are filled with the sign bit. */
-inline
-double_int double_int::from_shwi (HOST_WIDE_INT cst)
+inline double_int
+double_int::from_shwi (HOST_WIDE_INT cst)
{
double_int r;
r.low = (unsigned HOST_WIDE_INT) cst;
@@ -215,8 +220,8 @@ shwi_to_double_int (HOST_WIDE_INT cst)
/* Constructs double_int from unsigned integer CST. The bits over the
precision of HOST_WIDE_INT are filled with zeros. */
-inline
-double_int double_int::from_uhwi (unsigned HOST_WIDE_INT cst)
+inline double_int
+double_int::from_uhwi (unsigned HOST_WIDE_INT cst)
{
double_int r;
r.low = cst;
@@ -266,6 +271,27 @@ double_int::operator -= (double_int b)
return *this;
}
+inline double_int &
+double_int::operator &= (double_int b)
+{
+ *this = *this & b;
+ return *this;
+}
+
+inline double_int &
+double_int::operator ^= (double_int b)
+{
+ *this = *this ^ b;
+ return *this;
+}
+
+inline double_int &
+double_int::operator |= (double_int b)
+{
+ *this = *this | b;
+ return *this;
+}
+
/* Returns value of CST as a signed number. CST must satisfy
double_int::fits_signed. */
@@ -346,7 +372,9 @@ inline double_int
double_int_mul_with_sign (double_int a, double_int b,
bool unsigned_p, int *overflow)
{
- return a.mul_with_sign (b, unsigned_p, overflow);
+ bool ovf;
+ return a.mul_with_sign (b, unsigned_p, &ovf);
+ *overflow = ovf;
}
/* FIXME(crowl): Remove after converting callers. */