From 6584b4aa8bf0515432f520c3ac8379e3bd70e8d2 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 2 Apr 2002 23:56:47 -0800 Subject: [PATCH] re PR rtl-optimization/4311 (unrolling loops creates non-ending loop) PR opt/4311 * loop.h (LOOP_FIRST_PASS): New. * loop.c (strength_reduce): Mind it when deciding to unroll. * toplev.c (rest_of_compilation): Set it. From-SVN: r51798 --- gcc/ChangeLog | 7 +++++++ gcc/loop.c | 3 ++- gcc/loop.h | 1 + gcc/toplev.c | 3 +-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d4522513a73..5a4f4f324cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2002-04-02 Richard Henderson + + PR opt/4311 + * loop.h (LOOP_FIRST_PASS): New. + * loop.c (strength_reduce): Mind it when deciding to unroll. + * toplev.c (rest_of_compilation): Set it. + 2002-04-02 David S. Miller * config/sparc/sparc.md (ldd peephole2s): Fix final arg to diff --git a/gcc/loop.c b/gcc/loop.c index 99281d0dba4..b51b2a850d7 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -5214,7 +5214,8 @@ strength_reduce (loop, flags) collected. Always unroll loops that would be as small or smaller unrolled than when rolled. */ if ((flags & LOOP_UNROLL) - || (loop_info->n_iterations > 0 + || (!(flags & LOOP_FIRST_PASS) + && loop_info->n_iterations > 0 && unrolled_insn_copies <= insn_count)) unroll_loop (loop, insn_count, 1); diff --git a/gcc/loop.h b/gcc/loop.h index 55f70ff63d9..8e3a9351f36 100644 --- a/gcc/loop.h +++ b/gcc/loop.h @@ -28,6 +28,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #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) diff --git a/gcc/toplev.c b/gcc/toplev.c index 24009593366..9fa22fc9cdf 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2805,8 +2805,7 @@ rest_of_compilation (decl) cleanup_barriers (); /* We only want to perform unrolling once. */ - - loop_optimize (insns, rtl_dump_file, 0); + 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