optimization/8599: [3.2 regression] loop unroll bug with -march=k6-3
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Sun Dec 1 10:55:00 GMT 2002
On Sunday 01 December 2002 15:19, Franz Sirl wrote:
> On Saturday 30 November 2002 15:08, Eric Botcazou wrote:
> > > Now, the problematic part is the doloop.c hunk as I just verified. So
> > > we have to find out how to fix it or we have to revert the patch on the
> > > branch
> >
> > Try the attached patch.
>
> Neither with my version of the backport nor with yours the regression is
> fixed. But I can confirm that there is no such bug in the mainline.
This one backported fixes the branch regression:
2002-07-21 Richard Henderson <rth@redhat.com>
* loop.h (LOOP_AUTO_UNROLL): Rename from LOOP_FIRST_PASS.
* loop.c (strength_reduce): Update.
* toplev.c (rest_of_compilation): Do unrolling in the first
loop pass, not the second.
I'm running a branch bootstrap now on powerpc-linux-gnu and i686-linux-gnu.
Richard, do you think it's safe to move this patch to the branch? Do you
remember any prerequisites?
Franz.
-------------- next part --------------
Index: gcc/loop.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/loop.c,v
retrieving revision 1.389.2.7.2.5
diff -u -p -r1.389.2.7.2.5 loop.c
--- gcc/loop.c 22 Nov 2002 21:20:04 -0000 1.389.2.7.2.5
+++ gcc/loop.c 1 Dec 2002 18:52:55 -0000
@@ -5251,7 +5251,7 @@ strength_reduce (loop, flags)
collected. Always unroll loops that would be as small or smaller
unrolled than when rolled. */
if ((flags & LOOP_UNROLL)
- || (!(flags & LOOP_FIRST_PASS)
+ || ((flags & LOOP_AUTO_UNROLL)
&& loop_info->n_iterations > 0
&& unrolled_insn_copies <= insn_count))
unroll_loop (loop, insn_count, 1);
Index: gcc/loop.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/loop.h,v
retrieving revision 1.58.6.1.4.1
diff -u -p -r1.58.6.1.4.1 loop.h
--- gcc/loop.h 17 Sep 2002 03:25:06 -0000 1.58.6.1.4.1
+++ gcc/loop.h 1 Dec 2002 18:52:55 -0000
@@ -28,7 +28,7 @@ Software Foundation, 59 Temple Place - S
#define LOOP_UNROLL 1
#define LOOP_BCT 2
#define LOOP_PREFETCH 4
-#define LOOP_FIRST_PASS 8
+#define LOOP_AUTO_UNROLL 8
/* Get the loop info pointer of a loop. */
#define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux)
Index: gcc/toplev.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.574.2.16.2.3
diff -u -p -r1.574.2.16.2.3 toplev.c
--- gcc/toplev.c 2 Nov 2002 00:57:23 -0000 1.574.2.16.2.3
+++ gcc/toplev.c 1 Dec 2002 18:52:56 -0000
@@ -2890,16 +2890,21 @@ rest_of_compilation (decl)
if (optimize > 0)
{
+ int do_unroll, do_prefetch;
+
timevar_push (TV_LOOP);
open_dump_file (DFI_loop, decl);
free_bb_for_insn ();
+ do_unroll = flag_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
+ do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
if (flag_rerun_loop_opt)
{
cleanup_barriers ();
/* We only want to perform unrolling once. */
- loop_optimize (insns, rtl_dump_file, LOOP_FIRST_PASS);
+ loop_optimize (insns, rtl_dump_file, do_unroll);
+ do_unroll = 0;
/* The first call to loop_optimize makes some instructions
trivially dead. We delete those instructions now in the
@@ -2912,9 +2917,7 @@ rest_of_compilation (decl)
reg_scan (insns, max_reg_num (), 1);
}
cleanup_barriers ();
- loop_optimize (insns, rtl_dump_file,
- (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT
- | (flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0));
+ loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch);
close_dump_file (DFI_loop, print_rtl, insns);
timevar_pop (TV_LOOP);
More information about the Gcc-bugs
mailing list