This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/8599: [3.2 regression] loop unroll bug with -march=k6-3
> 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.
--
Eric Botcazou
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.331.2.2.2.2
diff -u -r1.331.2.2.2.2 rtl.h
--- rtl.h 16 Nov 2002 01:55:47 -0000 1.331.2.2.2.2
+++ rtl.h 30 Nov 2002 13:58:18 -0000
@@ -637,6 +637,7 @@
#define NOTE_LIVE_INFO(INSN) XCEXP (INSN, 3, NOTE)
#define NOTE_BASIC_BLOCK(INSN) XCBBDEF (INSN, 3, NOTE)
#define NOTE_EXPECTED_VALUE(INSN) XCEXP (INSN, 3, NOTE)
+#define NOTE_PRECONDITIONED(INSN) XCINT (INSN, 3, NOTE)
/* In a NOTE that is a line number, this is the line number.
Other kinds of NOTEs are identified by negative numbers here. */
Index: doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.16.8.3
diff -u -r1.16.8.3 doloop.c
--- doloop.c 22 Nov 2002 21:20:04 -0000 1.16.8.3
+++ doloop.c 30 Nov 2002 13:58:21 -0000
@@ -339,6 +339,7 @@
condition at run-time and have an additional jump around the loop
to ensure an infinite loop. */
if (loop_info->comparison_code == NE
+ && !loop_info->preconditioned
&& INTVAL (loop_info->increment) != -1
&& INTVAL (loop_info->increment) != 1)
{
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.389.2.7.2.5
diff -u -r1.389.2.7.2.5 loop.c
--- loop.c 22 Nov 2002 21:20:04 -0000 1.389.2.7.2.5
+++ loop.c 30 Nov 2002 13:58:48 -0000
@@ -2481,7 +2481,8 @@
loop_info->first_loop_store_insn = NULL_RTX;
loop_info->mems_idx = 0;
loop_info->num_mem_sets = 0;
-
+ /* If loop opts run twice, this was set on 1st pass for 2nd. */
+ loop_info->preconditioned = NOTE_PRECONDITIONED (end);
for (insn = start; insn && GET_CODE (insn) != CODE_LABEL;
insn = PREV_INSN (insn))
Index: unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/unroll.c,v
retrieving revision 1.160.2.4.2.3
diff -u -r1.160.2.4.2.3 unroll.c
--- unroll.c 3 Oct 2002 19:40:44 -0000 1.160.2.4.2.3
+++ unroll.c 30 Nov 2002 13:59:00 -0000
@@ -1191,6 +1191,9 @@
/* And whether the loop has been preconditioned. */
loop_info->preconditioned = loop_preconditioned;
+ /* Remember whether it was preconditioned for the second loop pass. */
+ NOTE_PRECONDITIONED (loop->end) = loop_preconditioned;
+
/* For each biv and giv, determine whether it can be safely split into
a different variable for each unrolled copy of the loop body.
We precalculate and save this info here, since computing it is