[PATCH] Fix PR46664
Richard Guenther
rguenther@suse.de
Fri Nov 26 13:41:00 GMT 2010
When aff_combination_add overflows MAX_AFF_ELTS it appends to ->rest
and for pointer typed combination does so in sizetype. This shows
an inconsistency wrt aff_combination_to_tree which starts with ->rest,
adding to a non-pointer even for pointer typed combinations.
It seems more natural to add ->rest last and assume that the first
element of the combination will be the pointer base. Starting with
->rest was probably done for efficiency reasons, not for code quality
or consistency with something else?
That way we won't end up creating a POINTER_PLUS_EXPR with bogus types
(looks like I was the one adding the pointer-plus-expr fixups to
tree-affine.c)
Bootstrap & regtest in progress on x86_64-unknown-linux-gnu.
Richard.
2010-11-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46664
* tree-affine.c (aff_combination_to_tree): Add rest last.
Index: gcc/tree-affine.c
===================================================================
*** gcc/tree-affine.c (revision 167170)
--- gcc/tree-affine.c (working copy)
*************** tree
*** 434,440 ****
aff_combination_to_tree (aff_tree *comb)
{
tree type = comb->type;
! tree expr = comb->rest;
unsigned i;
double_int off, sgn;
tree type1 = type;
--- 434,440 ----
aff_combination_to_tree (aff_tree *comb)
{
tree type = comb->type;
! tree expr = NULL_TREE;
unsigned i;
double_int off, sgn;
tree type1 = type;
*************** aff_combination_to_tree (aff_tree *comb)
*** 447,452 ****
--- 447,455 ----
expr = add_elt_to_tree (expr, type, comb->elts[i].val, comb->elts[i].coef,
comb);
+ if (comb->rest)
+ expr = add_elt_to_tree (expr, type, comb->rest, double_int_one, comb);
+
/* Ensure that we get x - 1, not x + (-1) or x + 0xff..f if x is
unsigned. */
if (double_int_negative_p (comb->offset))
More information about the Gcc-patches
mailing list