void aff_combination_elt (aff_tree *comb, tree type, tree elt) { aff_combination_zero (comb, type); comb->n = 1; comb->elts[0].val = elt; comb->elts[0].coef = double_int_one; }
void aff_combination_scale (aff_tree *comb, double_int scale) { unsigned i, j; scale = double_int_ext_for_comb (scale, comb); if (double_int_one_p (scale)) return; if (double_int_zero_p (scale)) { aff_combination_zero (comb, comb->type); return; } comb->offset = double_int_ext_for_comb (double_int_mul (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); /* A coefficient may become zero due to overflow. Remove the zero elements. */ if (double_int_zero_p (new_coef)) continue; comb->elts[j].coef = new_coef; comb->elts[j].val = comb->elts[i].val; j++; } comb->n = j; if (comb->rest) { tree type = comb->type; if (POINTER_TYPE_P (type)) type = sizetype; if (comb->n < MAX_AFF_ELTS) { comb->elts[comb->n].coef = scale; comb->elts[comb->n].val = comb->rest; comb->rest = NULL_TREE; comb->n++; } else comb->rest = fold_build2 (MULT_EXPR, type, comb->rest, double_int_to_tree (type, scale)); } }
void aff_combination_mult (aff_tree *c1, aff_tree *c2, aff_tree *r) { unsigned i; gcc_assert (TYPE_PRECISION (c1->type) == TYPE_PRECISION (c2->type)); aff_combination_zero (r, c1->type); for (i = 0; i < c2->n; i++) aff_combination_add_product (c1, c2->elts[i].coef, c2->elts[i].val, r); if (c2->rest) aff_combination_add_product (c1, double_int_one, c2->rest, r); aff_combination_add_product (c1, c2->offset, NULL, r); }
void tree_to_aff_combination_expand (tree expr, tree type, aff_tree *comb, struct pointer_map_t **cache) { unsigned i; aff_tree to_add, current, curre; tree e, def, rhs; double_int scale; void **slot; struct name_expansion *exp; tree_to_aff_combination (expr, type, comb); aff_combination_zero (&to_add, type); for (i = 0; i < comb->n; i++) { e = comb->elts[i].val; if (TREE_CODE (e) != SSA_NAME) continue; def = SSA_NAME_DEF_STMT (e); if (TREE_CODE (def) != GIMPLE_MODIFY_STMT || GIMPLE_STMT_OPERAND (def, 0) != e) continue; rhs = GIMPLE_STMT_OPERAND (def, 1); if (TREE_CODE (rhs) != SSA_NAME && !EXPR_P (rhs) && !is_gimple_min_invariant (rhs)) continue; /* We do not know whether the reference retains its value at the place where the expansion is used. */ if (REFERENCE_CLASS_P (rhs)) continue; if (!*cache) *cache = pointer_map_create (); slot = pointer_map_insert (*cache, e); exp = *slot; if (!exp) { exp = XNEW (struct name_expansion); exp->in_progress = 1; *slot = exp; tree_to_aff_combination_expand (rhs, type, ¤t, cache); exp->expansion = current; exp->in_progress = 0; } else {
void aff_combination_scale (aff_tree *comb, const widest_int &scale_in) { unsigned i, j; widest_int scale = wide_int_ext_for_comb (scale_in, comb->type); if (scale == 1) return; if (scale == 0) { aff_combination_zero (comb, comb->type); return; } comb->offset = wide_int_ext_for_comb (scale * comb->offset, comb->type); for (i = 0, j = 0; i < comb->n; i++) { widest_int new_coef = wide_int_ext_for_comb (scale * comb->elts[i].coef, comb->type); /* A coefficient may become zero due to overflow. Remove the zero elements. */ if (new_coef == 0) continue; comb->elts[j].coef = new_coef; comb->elts[j].val = comb->elts[i].val; j++; } comb->n = j; if (comb->rest) { tree type = comb->type; if (POINTER_TYPE_P (type)) type = sizetype; if (comb->n < MAX_AFF_ELTS) { comb->elts[comb->n].coef = scale; comb->elts[comb->n].val = comb->rest; comb->rest = NULL_TREE; comb->n++; } else comb->rest = fold_build2 (MULT_EXPR, type, comb->rest, wide_int_to_tree (type, scale)); } }
void aff_combination_mult (aff_tree *c1, aff_tree *c2, aff_tree *r) { unsigned i; gcc_assert (TYPE_PRECISION (c1->type) == TYPE_PRECISION (c2->type)); aff_combination_zero (r, c1->type); for (i = 0; i < c2->n; i++) aff_combination_add_product (c1, c2->elts[i].coef, c2->elts[i].val, r); if (c2->rest) aff_combination_add_product (c1, 1, c2->rest, r); if (c2->offset.is_constant ()) /* Access coeffs[0] directly, for efficiency. */ aff_combination_add_product (c1, c2->offset.coeffs[0], NULL, r); else { /* c2->offset is polynomial, so do the multiplication in tree form. */ tree offset = wide_int_to_tree (c2->type, c2->offset); aff_combination_add_product (c1, 1, offset, r); } }
void aff_combination_const (aff_tree *comb, tree type, double_int cst) { aff_combination_zero (comb, type); comb->offset = double_int_ext_for_comb (cst, comb); }
void aff_combination_const (aff_tree *comb, tree type, const poly_widest_int &cst) { aff_combination_zero (comb, type); comb->offset = wide_int_ext_for_comb (cst, comb->type);; }