From bdc453866cbd815b1d62d858272b8a40f8fdc9fa Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 5 Jul 2010 13:06:07 +0000 Subject: [PATCH] double-int.h (double_int_sub): Declare. 2010-07-05 Richard Guenther * double-int.h (double_int_sub): Declare. * double-int.c (double_int_sub): New function. * dwarf2out.c (field_byte_offset): Use it. * fixed-value.c (do_fixed_add): Likewise. (do_fixed_multiply): Likewise. (do_fixed_divide): Likewise. * tree-predcom.c (add_ref_to_chain): Likewise. (determine_roots_comp): Likewise. * tree-ssa-loop-niter.c (derive_constant_upper_bound_ops): Likewise. From-SVN: r161835 --- gcc/double-int.c | 11 +++++++++++ gcc/double-int.h | 1 + gcc/dwarf2out.c | 5 ++--- gcc/fixed-value.c | 12 ++++++------ gcc/tree-predcom.c | 5 ++--- gcc/tree-ssa-loop-niter.c | 4 ++-- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/gcc/double-int.c b/gcc/double-int.c index aa175e89d41..0bfe514238d 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -792,6 +792,17 @@ double_int_add (double_int a, double_int b) return ret; } +/* Returns A - B. */ + +double_int +double_int_sub (double_int a, double_int b) +{ + double_int ret; + neg_double (b.low, b.high, &b.low, &b.high); + add_double (a.low, a.high, b.low, b.high, &ret.low, &ret.high); + return ret; +} + /* Returns -A. */ double_int diff --git a/gcc/double-int.h b/gcc/double-int.h index 6af0757990c..1fa9d8818a7 100644 --- a/gcc/double-int.h +++ b/gcc/double-int.h @@ -133,6 +133,7 @@ double_int_fits_in_uhwi_p (double_int cst) double_int double_int_mul (double_int, double_int); double_int double_int_add (double_int, double_int); +double_int double_int_sub (double_int, double_int); double_int double_int_neg (double_int); /* You must ensure that double_int_ext is called on the operands diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 8e355450eef..55fef55ed3f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -15745,7 +15745,7 @@ field_byte_offset (const_tree decl) where the lowest addressed bit of the containing object must be. */ object_offset_in_bits - = double_int_add (deepest_bitpos, double_int_neg (type_size_in_bits)); + = double_int_sub (deepest_bitpos, type_size_in_bits); /* Round up to type_align by default. This works best for bitfields. */ @@ -15755,8 +15755,7 @@ field_byte_offset (const_tree decl) if (double_int_ucmp (object_offset_in_bits, bitpos_int) > 0) { object_offset_in_bits - = double_int_add (deepest_bitpos, - double_int_neg (type_size_in_bits)); + = double_int_sub (deepest_bitpos, type_size_in_bits); /* Round up to decl_align instead. */ object_offset_in_bits diff --git a/gcc/fixed-value.c b/gcc/fixed-value.c index 9af431cc8b7..50dc14ed59d 100644 --- a/gcc/fixed-value.c +++ b/gcc/fixed-value.c @@ -361,7 +361,7 @@ do_fixed_add (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, double_int one; one.low = 1; one.high = 0; - f->data = double_int_add (f->data, double_int_neg (one)); + f->data = double_int_sub (f->data, one); } } else @@ -443,12 +443,12 @@ do_fixed_multiply (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, temp1.high = 0; r = double_int_add (r, temp1); - /* We need to add neg(b) to r, if a < 0. */ + /* We need to subtract b from r, if a < 0. */ if (!unsigned_p && a->data.high < 0) - r = double_int_add (r, double_int_neg (b->data)); - /* We need to add neg(a) to r, if b < 0. */ + r = double_int_sub (r, b->data); + /* We need to subtract a from r, if b < 0. */ if (!unsigned_p && b->data.high < 0) - r = double_int_add (r, double_int_neg (a->data)); + r = double_int_sub (r, a->data); /* Shift right the result by FBIT. */ if (GET_MODE_FBIT (f->mode) == 2 * HOST_BITS_PER_WIDE_INT) @@ -588,7 +588,7 @@ do_fixed_divide (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, &quo_s.low, &quo_s.high, 0); /* Try to calculate (mod - pos_b). */ - temp = double_int_add (mod, double_int_neg (pos_b)); + temp = double_int_sub (mod, pos_b); if (leftmost_mod == 1 || double_int_cmp (mod, pos_b, 1) != -1) { diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index 4af074ff5e5..49683d5093b 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -925,7 +925,7 @@ add_ref_to_chain (chain_p chain, dref ref) double_int dist; gcc_assert (double_int_scmp (root->offset, ref->offset) <= 0); - dist = double_int_add (ref->offset, double_int_neg (root->offset)); + dist = double_int_sub (ref->offset, root->offset); if (double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE), dist) <= 0) { free (ref); @@ -1199,8 +1199,7 @@ determine_roots_comp (struct loop *loop, { if (!chain || !DR_IS_READ (a->ref) || double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE), - double_int_add (a->offset, - double_int_neg (last_ofs))) <= 0) + double_int_sub (a->offset, last_ofs)) <= 0) { if (nontrivial_chain_p (chain)) { diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 9956cc551b4..b343b60d35f 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2397,7 +2397,7 @@ derive_constant_upper_bound_ops (tree type, tree op0, /* OP0 + CST. We need to check that BND <= MAX (type) - CST. */ - mmax = double_int_add (max, double_int_neg (cst)); + mmax = double_int_sub (max, cst); if (double_int_ucmp (bnd, mmax) > 0) return max; @@ -2429,7 +2429,7 @@ derive_constant_upper_bound_ops (tree type, tree op0, return max; } - bnd = double_int_add (bnd, double_int_neg (cst)); + bnd = double_int_sub (bnd, cst); } return bnd;