This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: IVOPTS vs Ada subtypes and base types
Jeffrey A Law wrote:
>
> Note how the conversions have been lost.
>
This is a bug in chrec_convert_aggressive.
The following patch fixes the problem in a quite drastic way,
disabling the analysis of ivs that contain casts in their induction.
Index: tree-scalar-evolution.c
===================================================================
--- tree-scalar-evolution.c (revision 111416)
+++ tree-scalar-evolution.c (working copy)
@@ -1057,8 +1057,9 @@ follow_ssa_edge_in_rhs (struct loop *loo
/* This assignment is under the form "a_1 = (cast) rhs. */
res = follow_ssa_edge_in_rhs (loop, at_stmt, TREE_OPERAND (rhs, 0),
halting_phi, evolution_of_loop, limit);
- *evolution_of_loop = chrec_convert (TREE_TYPE (rhs),
- *evolution_of_loop, at_stmt);
+ if (res == t_true)
+ *evolution_of_loop = chrec_dont_know;
+
break;
case INTEGER_CST:
If we keep the conversions without performing the conversion, ie. the
next patch, later on we get the call to chrec_convert_aggressive that
will remove all the type casts, resulting in the endless loop.
Index: tree-scalar-evolution.c
===================================================================
--- tree-scalar-evolution.c (revision 111416)
+++ tree-scalar-evolution.c (working copy)
@@ -1057,8 +1057,9 @@ follow_ssa_edge_in_rhs (struct loop *loo
/* This assignment is under the form "a_1 = (cast) rhs. */
res = follow_ssa_edge_in_rhs (loop, at_stmt, TREE_OPERAND (rhs, 0),
halting_phi, evolution_of_loop, limit);
- *evolution_of_loop = chrec_convert (TREE_TYPE (rhs),
- *evolution_of_loop, at_stmt);
+ if (res == t_true)
+ *evolution_of_loop = build1 (NOP_EXPR, TREE_TYPE (rhs),
+ *evolution_of_loop);
break;
case INTEGER_CST: