/* Operations with affine combinations of trees.
- Copyright (C) 2005, 2007, 2008, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2005-2013 Free Software Foundation, Inc.
This file is part of GCC.
#include "system.h"
#include "coretypes.h"
#include "tree.h"
-#include "output.h"
#include "tree-pretty-print.h"
-#include "tree-dump.h"
#include "pointer-set.h"
#include "tree-affine.h"
#include "gimple.h"
#include "flags.h"
+#include "dumpfile.h"
/* Extends CST as appropriate for the affine combinations COMB. */
double_int
double_int_ext_for_comb (double_int cst, aff_tree *comb)
{
- return double_int_sext (cst, TYPE_PRECISION (comb->type));
+ return cst.sext (TYPE_PRECISION (comb->type));
}
/* Initializes affine combination COMB so that its value is zero in TYPE. */
unsigned i, j;
scale = double_int_ext_for_comb (scale, comb);
- if (double_int_one_p (scale))
+ if (scale.is_one ())
return;
- if (double_int_zero_p (scale))
+ if (scale.is_zero ())
{
aff_combination_zero (comb, comb->type);
return;
}
comb->offset
- = double_int_ext_for_comb (double_int_mul (scale, comb->offset), comb);
+ = double_int_ext_for_comb (scale * comb->offset, comb);
for (i = 0, j = 0; i < comb->n; i++)
{
double_int new_coef;
new_coef
- = double_int_ext_for_comb (double_int_mul (scale, comb->elts[i].coef),
- comb);
+ = double_int_ext_for_comb (scale * comb->elts[i].coef, comb);
/* A coefficient may become zero due to overflow. Remove the zero
elements. */
- if (double_int_zero_p (new_coef))
+ if (new_coef.is_zero ())
continue;
comb->elts[j].coef = new_coef;
comb->elts[j].val = comb->elts[i].val;
tree type;
scale = double_int_ext_for_comb (scale, comb);
- if (double_int_zero_p (scale))
+ if (scale.is_zero ())
return;
for (i = 0; i < comb->n; i++)
{
double_int new_coef;
- new_coef = double_int_add (comb->elts[i].coef, scale);
+ new_coef = comb->elts[i].coef + scale;
new_coef = double_int_ext_for_comb (new_coef, comb);
- if (!double_int_zero_p (new_coef))
+ if (!new_coef.is_zero ())
{
comb->elts[i].coef = new_coef;
return;
if (POINTER_TYPE_P (type))
type = sizetype;
- if (double_int_one_p (scale))
+ if (scale.is_one ())
elt = fold_convert (type, elt);
else
elt = fold_build2 (MULT_EXPR, type,
static void
aff_combination_add_cst (aff_tree *c, double_int cst)
{
- c->offset = double_int_ext_for_comb (double_int_add (c->offset, cst), c);
+ c->offset = double_int_ext_for_comb (c->offset + cst, c);
}
/* Adds COMB2 to COMB1. */
for (i = j = 0; i < comb->n; i++)
{
double_int new_coef = double_int_ext_for_comb (comb->elts[i].coef, comb);
- if (double_int_zero_p (new_coef))
+ if (new_coef.is_zero ())
continue;
comb->elts[j].coef = new_coef;
comb->elts[j].val = fold_convert (type, comb->elts[i].val);
if (bitpos % BITS_PER_UNIT != 0)
break;
aff_combination_const (comb, type,
- uhwi_to_double_int (bitpos / BITS_PER_UNIT));
+ double_int::from_uhwi (bitpos / BITS_PER_UNIT));
core = build_fold_addr_expr (core);
if (TREE_CODE (core) == ADDR_EXPR)
aff_combination_add_elt (comb, core, double_int_one);
scale = double_int_ext_for_comb (scale, comb);
elt = fold_convert (type1, elt);
- if (double_int_one_p (scale))
+ if (scale.is_one ())
{
if (!expr)
return fold_convert (type, elt);
return fold_build2 (PLUS_EXPR, type, expr, elt);
}
- if (double_int_minus_one_p (scale))
+ if (scale.is_minus_one ())
{
if (!expr)
return fold_convert (type, fold_build1 (NEGATE_EXPR, type1, elt));
fold_build2 (MULT_EXPR, type1, elt,
double_int_to_tree (type1, scale)));
- if (double_int_negative_p (scale))
+ if (scale.is_negative ())
{
code = MINUS_EXPR;
- scale = double_int_neg (scale);
+ scale = -scale;
}
else
code = PLUS_EXPR;
/* Ensure that we get x - 1, not x + (-1) or x + 0xff..f if x is
unsigned. */
- if (double_int_negative_p (comb->offset))
+ if (comb->offset.is_negative ())
{
- off = double_int_neg (comb->offset);
+ off = -comb->offset;
sgn = double_int_minus_one;
}
else
fold_convert (type, val));
}
- aff_combination_add_elt (r, aval,
- double_int_mul (coef, c->elts[i].coef));
+ aff_combination_add_elt (r, aval, coef * c->elts[i].coef);
}
if (c->rest)
}
if (val)
- aff_combination_add_elt (r, val,
- double_int_mul (coef, c->offset));
+ aff_combination_add_elt (r, val, coef * c->offset);
else
- aff_combination_add_cst (r, double_int_mul (coef, c->offset));
+ aff_combination_add_cst (r, coef * c->offset);
}
/* Multiplies C1 by C2, storing the result to R */
it from COMB. */
scale = comb->elts[i].coef;
aff_combination_zero (&curre, comb->type);
- aff_combination_add_elt (&curre, e, double_int_neg (scale));
+ aff_combination_add_elt (&curre, e, -scale);
aff_combination_scale (¤t, scale);
aff_combination_add (&to_add, ¤t);
aff_combination_add (&to_add, &curre);
{
double_int rem, cst;
- if (double_int_zero_p (val))
+ if (val.is_zero ())
return true;
- if (double_int_zero_p (div))
+ if (div.is_zero ())
return false;
- cst = double_int_sdivmod (val, div, FLOOR_DIV_EXPR, &rem);
- if (!double_int_zero_p (rem))
+ cst = val.sdivmod (div, FLOOR_DIV_EXPR, &rem);
+ if (!rem.is_zero ())
return false;
- if (*mult_set && !double_int_equal_p (*mult, cst))
+ if (*mult_set && *mult != cst)
return false;
*mult_set = true;
bool mult_set = false;
unsigned i;
- if (val->n == 0 && double_int_zero_p (val->offset))
+ if (val->n == 0 && val->offset.is_zero ())
{
*mult = double_int_zero;
return true;
/* Prints the affine VAL to the FILE. */
-void
+static void
print_aff (FILE *file, aff_tree *val)
{
unsigned i;
}
aff_combination_const (&tmp, sizetype,
- shwi_to_double_int (bitpos / BITS_PER_UNIT));
+ double_int::from_shwi (bitpos / BITS_PER_UNIT));
aff_combination_add (addr, &tmp);
- *size = shwi_to_double_int ((bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT);
+ *size = double_int::from_shwi ((bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT);
}
/* Returns true if a region of size SIZE1 at position 0 and a region of
return false;
d = diff->offset;
- if (double_int_negative_p (d))
+ if (d.is_negative ())
{
/* The second object is before the first one, we succeed if the last
element of the second object is before the start of the first one. */
- bound = double_int_add (d, double_int_add (size2, double_int_minus_one));
- return double_int_negative_p (bound);
+ bound = d + size2 + double_int_minus_one;
+ return bound.is_negative ();
}
else
{
/* We succeed if the second object starts after the first one ends. */
- return double_int_scmp (size1, d) <= 0;
+ return size1.sle (d);
}
}