[PATCH] Fix PR28776, ICE in build_polynomial_chrec
Sebastian Pop
sebastian.pop@cri.ensmp.fr
Tue Aug 22 14:04:00 GMT 2006
> 2006-08-22 Richard Guenther <rguenther@suse.de>
>
> PR middle-end/28776
> * tree-scalar-evolution.c (fold_used_pointer): Convert
> arguments to arithmetic expression to the chrecs type.
>
> * gcc.c-torture/compile/pr28776-1.c: New testcase.
> * gcc.c-torture/compile/pr28776-2.c: Likewise.
>
Ok, with a small change.
:REVIEWMAIL:
> Index: tree-scalar-evolution.c
> ===================================================================
> *** tree-scalar-evolution.c (revision 116318)
> --- tree-scalar-evolution.c (working copy)
> *************** fold_used_pointer (tree expr)
> *** 1847,1852 ****
> --- 1847,1854 ----
> if (new0 == op0 && new1 == op1)
> return expr;
>
> + new0 = chrec_convert (TREE_TYPE (expr), new0, NULL_TREE);
> + new1 = chrec_convert (TREE_TYPE (expr), new1, NULL_TREE);
I'm seeing that fold_used_pointer is currently used only in a
MODIFY_EXPR case in analyze_scalar_evolution_1, that means that you
can add an extra "at_stmt" argument to fold_used_pointer and pass it
to chrec_convert instead of passing NULL_TREE. The conversion will
just have more precise information. Try something like the following
patch.
Thanks,
Sebastian
Index: tree-scalar-evolution.c
===================================================================
--- tree-scalar-evolution.c (revision 116321)
+++ tree-scalar-evolution.c (working copy)
@@ -1765,7 +1765,8 @@ pointer_offset_p (tree expr)
/* EXPR is a scalar evolution of a pointer that is dereferenced or used in
comparison. This means that it must point to a part of some object in
memory, which enables us to argue about overflows and possibly simplify
- the EXPR. Returns the simplified value.
+ the EXPR. AT_STMT is the statement in which this conversion has to be
+ performed. Returns the simplified value.
Currently, for
@@ -1820,7 +1821,7 @@ pointer_offset_p (tree expr)
bugs. */
static tree
-fold_used_pointer (tree expr)
+fold_used_pointer (tree expr, tree at_stmt)
{
tree op0, op1, new0, new1;
enum tree_code code = TREE_CODE (expr);
@@ -1833,13 +1834,13 @@ fold_used_pointer (tree expr)
if (pointer_offset_p (op1))
{
- new0 = fold_used_pointer (op0);
+ new0 = fold_used_pointer (op0, at_stmt);
new1 = fold_used_pointer_cast (op1);
}
else if (code == PLUS_EXPR && pointer_offset_p (op0))
{
new0 = fold_used_pointer_cast (op0);
- new1 = fold_used_pointer (op1);
+ new1 = fold_used_pointer (op1, at_stmt);
}
else
return expr;
@@ -1847,6 +1848,9 @@ fold_used_pointer (tree expr)
if (new0 == op0 && new1 == op1)
return expr;
+ new0 = chrec_convert (TREE_TYPE (expr), new0, at_stmt);
+ new1 = chrec_convert (TREE_TYPE (expr), new1, at_stmt);
+
if (code == PLUS_EXPR)
expr = chrec_fold_plus (TREE_TYPE (expr), new0, new1);
else
@@ -1948,7 +1952,7 @@ analyze_scalar_evolution_1 (struct loop
if (POINTER_TYPE_P (type)
&& !automatically_generated_chrec_p (res)
&& pointer_used_p (var))
- res = fold_used_pointer (res);
+ res = fold_used_pointer (res, def);
break;
case PHI_NODE:
More information about the Gcc-patches
mailing list