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)); } }
int gfc_interpret_logical (int kind, unsigned char *buffer, size_t buffer_size, int *logical) { tree t = native_interpret_expr (gfc_get_logical_type (kind), buffer, buffer_size); *logical = double_int_zero_p (tree_to_double_int (t)) ? 0 : 1; return size_logical (kind); }
static void addr_to_parts (tree type, aff_tree *addr, tree iv_cand, tree base_hint, struct mem_address *parts, bool speed) { tree part; unsigned i; parts->symbol = NULL_TREE; parts->base = NULL_TREE; parts->index = NULL_TREE; parts->step = NULL_TREE; if (!double_int_zero_p (addr->offset)) parts->offset = double_int_to_tree (sizetype, addr->offset); else parts->offset = NULL_TREE; /* Try to find a symbol. */ move_fixed_address_to_symbol (parts, addr); /* No need to do address parts reassociation if the number of parts is <= 2 -- in that case, no loop invariant code motion can be exposed. */ if (!base_hint && (addr->n > 2)) move_variant_to_index (parts, addr, iv_cand); /* First move the most expensive feasible multiplication to index. */ if (!parts->index) most_expensive_mult_to_index (type, parts, addr, speed); /* Try to find a base of the reference. Since at the moment there is no reliable way how to distinguish between pointer and its offset, this is just a guess. */ if (!parts->symbol && base_hint) move_hint_to_base (type, parts, base_hint, addr); if (!parts->symbol && !parts->base) move_pointer_to_base (parts, addr); /* Then try to process the remaining elements. */ for (i = 0; i < addr->n; i++) { part = fold_convert (sizetype, addr->elts[i].val); if (!double_int_one_p (addr->elts[i].coef)) part = fold_build2 (MULT_EXPR, sizetype, part, double_int_to_tree (sizetype, addr->elts[i].coef)); add_to_parts (parts, part); } if (addr->rest) add_to_parts (parts, fold_convert (sizetype, addr->rest)); }
static void myprof_read_loop ( struct loop *l ) { struct loop *inner; fprintf ( stderr, " # loop %d", l->num ); if ( double_int_zero_p(l->nb_iterations_estimate) ) /* double_int type defined in double-int.h */ fprintf ( stderr, " has unknown number of iterations" ); else fprintf ( stderr, " has %lu iterations", l->nb_iterations_estimate.low ); /* fprintf ( stderr, "\n" );*/ for ( inner=l->inner; inner!=NULL; inner=inner->next ) myprof_read_loop ( inner ); }
void aff_combination_convert (aff_tree *comb, tree type) { unsigned i, j; tree comb_type = comb->type; if (TYPE_PRECISION (type) > TYPE_PRECISION (comb_type)) { tree val = fold_convert (type, aff_combination_to_tree (comb)); tree_to_aff_combination (val, type, comb); return; } comb->type = type; if (comb->rest && !POINTER_TYPE_P (type)) comb->rest = fold_convert (type, comb->rest); if (TYPE_PRECISION (type) == TYPE_PRECISION (comb_type)) return; comb->offset = double_int_ext_for_comb (comb->offset, comb); 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)) continue; comb->elts[j].coef = new_coef; comb->elts[j].val = fold_convert (type, comb->elts[i].val); j++; } comb->n = j; if (comb->n < MAX_AFF_ELTS && comb->rest) { comb->elts[comb->n].coef = double_int_one; comb->elts[comb->n].val = comb->rest; comb->rest = NULL_TREE; comb->n++; } }
void aff_combination_add_elt (aff_tree *comb, tree elt, double_int scale) { unsigned i; tree type; scale = double_int_ext_for_comb (scale, comb); if (double_int_zero_p (scale)) return; for (i = 0; i < comb->n; i++) if (operand_equal_p (comb->elts[i].val, elt, 0)) { double_int new_coef; new_coef = double_int_add (comb->elts[i].coef, scale); new_coef = double_int_ext_for_comb (new_coef, comb); if (!double_int_zero_p (new_coef)) { comb->elts[i].coef = new_coef; return; } comb->n--; comb->elts[i] = comb->elts[comb->n]; if (comb->rest) { gcc_assert (comb->n == MAX_AFF_ELTS - 1); comb->elts[comb->n].coef = double_int_one; comb->elts[comb->n].val = comb->rest; comb->rest = NULL_TREE; comb->n++; } return; } if (comb->n < MAX_AFF_ELTS) { comb->elts[comb->n].coef = scale; comb->elts[comb->n].val = elt; comb->n++; return; } type = comb->type; if (POINTER_TYPE_P (type)) type = sizetype; if (double_int_one_p (scale)) elt = fold_convert (type, elt); else elt = fold_build2 (MULT_EXPR, type, fold_convert (type, elt), double_int_to_tree (type, scale)); if (comb->rest) comb->rest = fold_build2 (PLUS_EXPR, type, comb->rest, elt); else comb->rest = elt; }