fix opt/4311
Richard Henderson
rth@redhat.com
Wed Apr 3 00:06:00 GMT 2002
The problem is that we tried to unroll the loop twice and got confused.
Fixed by adding a flag telling the loop optimizer that it'll get another
chance to auto-unroll the loop.
Not sure how to render the test for the testsuite, since even success
runs the loop a very large number of times, and the bug requires that
we see integer overflow. Setting the start of the iteration large
seems to defeat the bug as well. Ho hum.
r~
* loop.h (LOOP_FIRST_PASS): New.
* loop.c (strength_reduce): Mind it when deciding to unroll.
* toplev.c (rest_of_compilation): Set it.
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.389.2.2
diff -c -p -d -r1.389.2.2 loop.c
*** loop.c 2002/03/13 07:34:55 1.389.2.2
--- loop.c 2002/04/03 07:49:50
*************** strength_reduce (loop, flags)
*** 5213,5219 ****
collected. Always unroll loops that would be as small or smaller
unrolled than when rolled. */
if ((flags & LOOP_UNROLL)
! || (loop_info->n_iterations > 0
&& unrolled_insn_copies <= insn_count))
unroll_loop (loop, insn_count, 1);
--- 5213,5220 ----
collected. Always unroll loops that would be as small or smaller
unrolled than when rolled. */
if ((flags & LOOP_UNROLL)
! || (!(flags & LOOP_FIRST_PASS)
! && loop_info->n_iterations > 0
&& unrolled_insn_copies <= insn_count))
unroll_loop (loop, insn_count, 1);
Index: loop.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.h,v
retrieving revision 1.58
diff -c -p -d -r1.58 loop.h
*** loop.h 2002/01/03 04:59:07 1.58
--- loop.h 2002/04/03 07:49:50
*************** Software Foundation, 59 Temple Place - S
*** 28,33 ****
--- 28,34 ----
#define LOOP_UNROLL 1
#define LOOP_BCT 2
#define LOOP_PREFETCH 4
+ #define LOOP_FIRST_PASS 8
/* Get the loop info pointer of a loop. */
#define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux)
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.574.2.6
diff -c -p -d -r1.574.2.6 toplev.c
*** toplev.c 2002/03/27 18:49:06 1.574.2.6
--- toplev.c 2002/04/03 07:49:50
*************** rest_of_compilation (decl)
*** 2877,2884 ****
cleanup_barriers ();
/* We only want to perform unrolling once. */
!
! loop_optimize (insns, rtl_dump_file, 0);
/* The first call to loop_optimize makes some instructions
trivially dead. We delete those instructions now in the
--- 2877,2883 ----
cleanup_barriers ();
/* We only want to perform unrolling once. */
! loop_optimize (insns, rtl_dump_file, LOOP_FIRST_PASS);
/* The first call to loop_optimize makes some instructions
trivially dead. We delete those instructions now in the
More information about the Gcc-patches
mailing list