Home | History | Annotate | Download | only in gcc

Lines Matching refs:comb

36 /* Extends CST as appropriate for the affine combinations COMB.  */
52 /* Initializes affine combination COMB so that its value is zero in TYPE. */
55 aff_combination_zero (aff_tree *comb, tree type)
58 comb->type = type;
59 comb->offset = 0;
60 comb->n = 0;
62 comb->elts[i].coef = 0;
63 comb->rest = NULL_TREE;
66 /* Sets COMB to CST. */
69 aff_combination_const (aff_tree *comb, tree type, const poly_widest_int &cst)
71 aff_combination_zero (comb, type);
72 comb->offset = wide_int_ext_for_comb (cst, comb->type);;
75 /* Sets COMB to single element ELT. */
78 aff_combination_elt (aff_tree *comb, tree type, tree elt)
80 aff_combination_zero (comb, type);
82 comb->n = 1;
83 comb->elts[0].val = elt;
84 comb->elts[0].coef = 1;
87 /* Scales COMB by SCALE. */
90 aff_combination_scale (aff_tree *comb, const widest_int &scale_in)
94 widest_int scale = wide_int_ext_for_comb (scale_in, comb->type);
100 aff_combination_zero (comb, comb->type);
104 comb->offset = wide_int_ext_for_comb (scale * comb->offset, comb->type);
105 for (i = 0, j = 0; i < comb->n; i++)
108 = wide_int_ext_for_comb (scale * comb->elts[i].coef, comb->type);
113 comb->elts[j].coef = new_coef;
114 comb->elts[j].val = comb->elts[i].val;
117 comb->n = j;
119 if (comb->rest)
121 tree type = comb->type;
124 if (comb->n < MAX_AFF_ELTS)
126 comb->elts[comb->n].coef = scale;
127 comb->elts[comb->n].val = comb->rest;
128 comb->rest = NULL_TREE;
129 comb->n++;
132 comb->rest = fold_build2 (MULT_EXPR, type, comb->rest,
137 /* Adds ELT * SCALE to COMB. */
140 aff_combination_add_elt (aff_tree *comb, tree elt, const widest_int &scale_in)
145 widest_int scale = wide_int_ext_for_comb (scale_in, comb->type);
149 for (i = 0; i < comb->n; i++)
150 if (operand_equal_p (comb->elts[i].val, elt, 0))
153 = wide_int_ext_for_comb (comb->elts[i].coef + scale, comb->type);
156 comb->elts[i].coef = new_coef;
160 comb->n--;
161 comb->elts[i] = comb->elts[comb->n];
163 if (comb->rest)
165 gcc_assert (comb->n == MAX_AFF_ELTS - 1);
166 comb->elts[comb->n].coef = 1;
167 comb->elts[comb->n].val = comb->rest;
168 comb->rest = NULL_TREE;
169 comb->n++;
173 if (comb->n < MAX_AFF_ELTS)
175 comb->elts[comb->n].coef = scale;
176 comb->elts[comb->n].val = elt;
177 comb->n++;
181 type = comb->type;
192 if (comb->rest)
193 comb->rest = fold_build2 (PLUS_EXPR, type, comb->rest,
196 comb->rest = elt;
221 /* Converts affine combination COMB to TYPE. */
224 aff_combination_convert (aff_tree *comb, tree type)
227 tree comb_type = comb->type;
231 tree val = fold_convert (type, aff_combination_to_tree (comb));
232 tree_to_aff_combination (val, type, comb);
236 comb->type = type;
237 if (comb->rest && !POINTER_TYPE_P (type))
238 comb->rest = fold_convert (type, comb->rest);
243 comb->offset = wide_int_ext_for_comb (comb->offset, comb->type);
244 for (i = j = 0; i < comb->n; i++)
246 if (comb->elts[i].coef == 0)
248 comb->elts[j].coef = comb->elts[i].coef;
249 comb->elts[j].val = fold_convert (type, comb->elts[i].val);
253 comb->n = j;
254 if (comb->n < MAX_AFF_ELTS && comb->rest)
256 comb->elts[comb->n].coef = 1;
257 comb->elts[comb->n].val = comb->rest;
258 comb->rest = NULL_TREE;
259 comb->n++;
264 true when that was successful and returns the combination in COMB. */
267 expr_to_aff_combination (aff_tree *comb, tree_code code, tree type,
276 tree_to_aff_combination (op0, type, comb);
278 aff_combination_add (comb, &tmp);
283 tree_to_aff_combination (op0, type, comb);
287 aff_combination_add (comb, &tmp);
293 tree_to_aff_combination (op0, type, comb);
294 aff_combination_scale (comb, wi::to_widest (op1));
298 tree_to_aff_combination (op0, type, comb);
299 aff_combination_scale (comb, -1);
304 tree_to_aff_combination (op0, type, comb);
305 aff_combination_scale (comb, -1);
306 aff_combination_add_cst (comb, -1);
319 tree_to_aff_combination (op0, type, comb);
342 return expr_to_aff_combination (comb, icode, otype, op0, op1);
371 return expr_to_aff_combination (comb, icode, otype, op0,
388 tree_to_aff_combination (tree expr, tree type, aff_tree *comb)
406 if (expr_to_aff_combination (comb, code, type, TREE_OPERAND (expr, 0),
413 if (expr_to_aff_combination (comb, code, type, TREE_OPERAND (expr, 0)))
420 if (expr_to_aff_combination (comb, code,
423 aff_combination_convert (comb, type);
433 tree_to_aff_combination (TREE_OPERAND (expr, 0), type, comb);
435 aff_combination_add (comb, &tmp);
443 aff_combination_const (comb, type, bytepos);
447 aff_combination_add_cst (comb, wi::to_poly_widest (mem_offset));
454 aff_combination_add_elt (comb, core, 1);
458 aff_combination_add (comb, &tmp);
463 aff_combination_add (comb, &tmp);
471 aff_combination_const (comb, type, wi::to_poly_widest (expr));
478 aff_combination_elt (comb, type, expr);
482 combination COMB. */
523 /* Makes tree from the affine combination COMB. */
526 aff_combination_to_tree (aff_tree *comb)
528 tree type = comb->type, base = NULL_TREE, expr = NULL_TREE;
533 gcc_assert (comb->n == MAX_AFF_ELTS || comb->rest == NULL_TREE);
539 if (comb->n > 0 && comb->elts[0].coef == 1
540 && POINTER_TYPE_P (TREE_TYPE (comb->elts[0].val)))
542 base = comb->elts[0].val;
547 for (; i < comb->n; i++)
548 expr = add_elt_to_tree (expr, type, comb->elts[i].val, comb->elts[i].coef);
550 if (comb->rest)
551 expr = add_elt_to_tree (expr, type, comb->rest, 1);
555 if (known_lt (comb->offset, 0))
557 off = -comb->offset;
562 off = comb->offset;
570 return fold_convert (comb->type, expr);
573 /* Copies the tree elements of COMB to ensure that they are not shared. */
576 unshare_aff_combination (aff_tree *comb)
580 for (i = 0; i < comb->n; i++)
581 comb->elts[i].val = unshare_expr (comb->elts[i].val);
582 if (comb->rest)
583 comb->rest = unshare_expr (comb->rest);
586 /* Remove M-th element from COMB. */
589 aff_combination_remove_elt (aff_tree *comb, unsigned m)
591 comb->n--;
592 if (m <= comb->n)
593 comb->elts[m] = comb->elts[comb->n];
594 if (comb->rest)
596 comb->elts[comb->n].coef = 1;
597 comb->elts[comb->n].val = comb->rest;
598 comb->rest = NULL_TREE;
599 comb->n++;
683 /* Returns the element of COMB whose value is VAL, or NULL if no such
685 COMB. */
688 aff_combination_find_elt (aff_tree *comb, tree val, unsigned *idx)
692 for (i = 0; i < comb->n; i++)
693 if (operand_equal_p (comb->elts[i].val, val, 0))
698 return &comb->elts[i];
716 /* Expands SSA names in COMB recursively. CACHE is used to cache the
720 aff_combination_expand (aff_tree *comb ATTRIBUTE_UNUSED,
730 aff_combination_zero (&to_add, comb->type);
731 for (i = 0; i < comb->n; i++)
736 e = comb->elts[i].val;
823 if (!useless_type_conversion_p (comb->type, current.type))
824 aff_combination_convert (&current, comb->type);
827 COMB while traversing it; include the term -coef * E, to remove
828 it from COMB. */
829 scale = comb->elts[i].coef;
830 aff_combination_zero (&curre, comb->type);
836 aff_combination_add (comb, &to_add);
850 tree_to_aff_combination_expand (tree expr, tree type, aff_tree *comb,
853 tree_to_aff_combination (expr, type, comb);
854 aff_combination_expand (comb, cache);