double-int.h (double_int_sub): Declare.

2010-07-05  Richard Guenther  <rguenther@suse.de>

	* 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
This commit is contained in:
Richard Biener 2010-07-05 13:06:07 +00:00
parent 989ea525be
commit bdc453866c
6 changed files with 24 additions and 14 deletions

View File

@ -792,6 +792,17 @@ double_int_add (double_int a, double_int b)
return ret; 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. */ /* Returns -A. */
double_int double_int

View File

@ -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_mul (double_int, double_int);
double_int double_int_add (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); double_int double_int_neg (double_int);
/* You must ensure that double_int_ext is called on the operands /* You must ensure that double_int_ext is called on the operands

View File

@ -15745,7 +15745,7 @@ field_byte_offset (const_tree decl)
where the lowest addressed bit of the containing object must where the lowest addressed bit of the containing object must
be. */ be. */
object_offset_in_bits 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 /* Round up to type_align by default. This works best for
bitfields. */ bitfields. */
@ -15755,8 +15755,7 @@ field_byte_offset (const_tree decl)
if (double_int_ucmp (object_offset_in_bits, bitpos_int) > 0) if (double_int_ucmp (object_offset_in_bits, bitpos_int) > 0)
{ {
object_offset_in_bits object_offset_in_bits
= double_int_add (deepest_bitpos, = double_int_sub (deepest_bitpos, type_size_in_bits);
double_int_neg (type_size_in_bits));
/* Round up to decl_align instead. */ /* Round up to decl_align instead. */
object_offset_in_bits object_offset_in_bits

View File

@ -361,7 +361,7 @@ do_fixed_add (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a,
double_int one; double_int one;
one.low = 1; one.low = 1;
one.high = 0; one.high = 0;
f->data = double_int_add (f->data, double_int_neg (one)); f->data = double_int_sub (f->data, one);
} }
} }
else else
@ -443,12 +443,12 @@ do_fixed_multiply (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a,
temp1.high = 0; temp1.high = 0;
r = double_int_add (r, temp1); 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) if (!unsigned_p && a->data.high < 0)
r = double_int_add (r, double_int_neg (b->data)); r = double_int_sub (r, b->data);
/* We need to add neg(a) to r, if b < 0. */ /* We need to subtract a from r, if b < 0. */
if (!unsigned_p && b->data.high < 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. */ /* Shift right the result by FBIT. */
if (GET_MODE_FBIT (f->mode) == 2 * HOST_BITS_PER_WIDE_INT) 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); &quo_s.low, &quo_s.high, 0);
/* Try to calculate (mod - pos_b). */ /* 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) if (leftmost_mod == 1 || double_int_cmp (mod, pos_b, 1) != -1)
{ {

View File

@ -925,7 +925,7 @@ add_ref_to_chain (chain_p chain, dref ref)
double_int dist; double_int dist;
gcc_assert (double_int_scmp (root->offset, ref->offset) <= 0); 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) if (double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE), dist) <= 0)
{ {
free (ref); free (ref);
@ -1199,8 +1199,7 @@ determine_roots_comp (struct loop *loop,
{ {
if (!chain || !DR_IS_READ (a->ref) if (!chain || !DR_IS_READ (a->ref)
|| double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE), || double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE),
double_int_add (a->offset, double_int_sub (a->offset, last_ofs)) <= 0)
double_int_neg (last_ofs))) <= 0)
{ {
if (nontrivial_chain_p (chain)) if (nontrivial_chain_p (chain))
{ {

View File

@ -2397,7 +2397,7 @@ derive_constant_upper_bound_ops (tree type, tree op0,
/* OP0 + CST. We need to check that /* OP0 + CST. We need to check that
BND <= MAX (type) - CST. */ 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) if (double_int_ucmp (bnd, mmax) > 0)
return max; return max;
@ -2429,7 +2429,7 @@ derive_constant_upper_bound_ops (tree type, tree op0,
return max; return max;
} }
bnd = double_int_add (bnd, double_int_neg (cst)); bnd = double_int_sub (bnd, cst);
} }
return bnd; return bnd;