This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Loop optimization bug with Ada front end on PPC (and probably Alpha)
Unforunately, this causes my original problem to come back. I'm nervous
about this patch, too, I don't understand it at all.
The loop where the problem occurred in the regression was reversed after
this was done, but I turned off the reversal and it had the same
problem. But it looks like the rest of the loop optimization code
handles this (jumping over the first increment) situation correctly, the
only problem occurrred in the doloop code.
I tried moving this test to doloop_modify_runtime in doloop.c and adding
the increment to the "diff" rtx in this situation, and it works in my
simple testcase and didn't cause the problem in the regression. I
haven't bootstrapped or run any tests yet, and I can't test the ia64
case with it. But I'll start a bootstrap now.
-Corey
Richard Henderson wrote:
>I've got a hack that appears to work -- the start label
>must be before the CONT marker.
>
>I'm nervous about this patch now, because I don't think
>we really understand the exact situation in which the
>original problem can ocurr. But as I've as yet got no
>further failures to look at, I'll commit it anyway.
>
Index: doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.12
diff -u -p -r1.12 doloop.c
--- doloop.c 2001/11/16 02:26:38 1.12
+++ doloop.c 2001/11/27 19:45:17
@@ -546,6 +546,8 @@ doloop_modify_runtime (loop, iterations_
rtx increment;
int unsigned_p;
enum rtx_code comparison_code;
+ struct loop_ivs *ivs = LOOP_IVS (loop);
+ struct iv_class *bl = REG_IV_CLASS (ivs, REGNO (loop_info->iteration_var));
increment = loop_info->increment;
initial_value = loop_info->initial_value;
@@ -595,6 +597,24 @@ doloop_modify_runtime (loop, iterations_
copy_rtx (neg_inc ? initial_value : final_value),
copy_rtx (neg_inc ? final_value : initial_value),
NULL_RTX, unsigned_p, OPTAB_LIB_WIDEN);
+
+ if (loop->top
+ && reg_set_between_p (bl->biv->src_reg, loop->top, loop->scan_start))
+ {
+ if (loop_dump_stream)
+ fprintf (loop_dump_stream,
+ "Loop iterations: Basic induction var skips initial incr.\n");
+ if (GET_CODE (increment) != CONST_INT)
+ {
+ if (loop_dump_stream)
+ fprintf (loop_dump_stream,
+ "Loop iterations: Can't adjust with non-constant incr.\n");
+ return 0;
+ }
+ diff = expand_simple_binop (GET_MODE (diff), PLUS,
+ diff, GEN_INT (INTVAL (increment)),
+ NULL_RTX, 1, OPTAB_LIB_WIDEN);
+ }
if (abs_inc * loop_info->unroll_number != 1)
{