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->n++;
}
else
- comb->rest = fold_build2 (MULT_EXPR, comb->type, comb->rest,
- double_int_to_tree (comb->type, scale));
+ comb->rest = fold_build2 (MULT_EXPR, type, comb->rest,
+ double_int_to_tree (type, scale));
}
}
double_int_to_tree (type, scale));
if (comb->rest)
- {
- if (POINTER_TYPE_P (comb->type))
- comb->rest = fold_build2 (POINTER_PLUS_EXPR, comb->type,
- comb->rest, elt);
- else
- comb->rest = fold_build2 (PLUS_EXPR, comb->type, comb->rest,
- elt);
- }
+ comb->rest = fold_build2 (PLUS_EXPR, type, comb->rest,
+ elt);
else
comb->rest = elt;
}
}
comb->type = type;
- if (comb->rest)
+ if (comb->rest && !POINTER_TYPE_P (type))
comb->rest = fold_convert (type, comb->rest);
if (TYPE_PRECISION (type) == TYPE_PRECISION (comb_type))
case POINTER_PLUS_EXPR:
tree_to_aff_combination (TREE_OPERAND (expr, 0), type, comb);
tree_to_aff_combination (TREE_OPERAND (expr, 1), sizetype, &tmp);
- aff_combination_convert (&tmp, type);
aff_combination_add (comb, &tmp);
return;
aff_tree *comb)
{
enum tree_code code;
+ tree type1 = type;
+ if (POINTER_TYPE_P (type))
+ type1 = sizetype;
scale = double_int_ext_for_comb (scale, comb);
- elt = fold_convert (type, elt);
+ elt = fold_convert (type1, elt);
if (double_int_one_p (scale))
{
if (!expr)
- return elt;
+ return fold_convert (type, elt);
+ if (POINTER_TYPE_P (type))
+ return fold_build2 (POINTER_PLUS_EXPR, type, expr, elt);
return fold_build2 (PLUS_EXPR, type, expr, elt);
}
if (double_int_minus_one_p (scale))
{
if (!expr)
- return fold_build1 (NEGATE_EXPR, type, elt);
+ return fold_convert (type, fold_build1 (NEGATE_EXPR, type1, elt));
+ if (POINTER_TYPE_P (type))
+ {
+ elt = fold_build1 (NEGATE_EXPR, type1, elt);
+ return fold_build2 (POINTER_PLUS_EXPR, type, expr, elt);
+ }
return fold_build2 (MINUS_EXPR, type, expr, elt);
}
if (!expr)
- return fold_build2 (MULT_EXPR, type, elt,
- double_int_to_tree (type, scale));
+ return fold_convert (type,
+ fold_build2 (MULT_EXPR, type1, elt,
+ double_int_to_tree (type1, scale)));
if (double_int_negative_p (scale))
{
else
code = PLUS_EXPR;
- elt = fold_build2 (MULT_EXPR, type, elt,
- double_int_to_tree (type, scale));
+ elt = fold_build2 (MULT_EXPR, type1, elt,
+ double_int_to_tree (type1, scale));
+ if (POINTER_TYPE_P (type))
+ {
+ if (code == MINUS_EXPR)
+ elt = fold_build1 (NEGATE_EXPR, type1, elt);
+ return fold_build2 (POINTER_PLUS_EXPR, type, expr, elt);
+ }
return fold_build2 (code, type, expr, elt);
}
tree expr = comb->rest;
unsigned i;
double_int off, sgn;
+ tree type1 = type;
+ if (POINTER_TYPE_P (type))
+ type1 = sizetype;
gcc_assert (comb->n == MAX_AFF_ELTS || comb->rest == NULL_TREE);
off = comb->offset;
sgn = double_int_one;
}
- return add_elt_to_tree (expr, type, double_int_to_tree (type, off), sgn,
+ return add_elt_to_tree (expr, type, double_int_to_tree (type1, off), sgn,
comb);
}
pointer_map_traverse. */
static bool
-free_name_expansion (void *key ATTRIBUTE_UNUSED, void **value,
+free_name_expansion (const void *key ATTRIBUTE_UNUSED, void **value,
void *data ATTRIBUTE_UNUSED)
{
struct name_expansion *exp = *value;
gcc_assert (mult_set);
return true;
}
+
+/* Prints the affine VAL to the FILE. */
+
+void
+print_aff (FILE *file, aff_tree *val)
+{
+ unsigned i;
+ bool uns = TYPE_UNSIGNED (val->type);
+ if (POINTER_TYPE_P (val->type))
+ uns = false;
+ fprintf (file, "{\n type = ");
+ print_generic_expr (file, val->type, TDF_VOPS|TDF_MEMSYMS);
+ fprintf (file, "\n offset = ");
+ dump_double_int (file, val->offset, uns);
+ if (val->n > 0)
+ {
+ fprintf (file, "\n elements = {\n");
+ for (i = 0; i < val->n; i++)
+ {
+ fprintf (file, " [%d] = ", i);
+ print_generic_expr (file, val->elts[i].val, TDF_VOPS|TDF_MEMSYMS);
+
+ fprintf (file, " * ");
+ dump_double_int (file, val->elts[i].coef, uns);
+ if (i != val->n - 1)
+ fprintf (file, ", \n");
+ }
+ fprintf (file, "\n }");
+ }
+ if (val->rest)
+ {
+ fprintf (file, "\n rest = ");
+ print_generic_expr (file, val->rest, TDF_VOPS|TDF_MEMSYMS);
+ }
+ fprintf (file, "\n}");
+}
+
+/* Prints the affine VAL to the standard error, used for debugging. */
+
+void
+debug_aff (aff_tree *val)
+{
+ print_aff (stderr, val);
+ fprintf (stderr, "\n");
+}