This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] doloop_optimize miscompiles openssl


On Sun, 24 Sep 2000, Franz Sirl wrote:
> 	* doloop.c (doloop_modify): Prevent delete_insn() from deleting too much.
> 	Use loop->top as target for the new JUMP insn.
>
> Index: gcc/doloop.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/doloop.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 doloop.c
> --- gcc/doloop.c	2000/08/14 20:55:11	1.2
> +++ gcc/doloop.c	2000/09/24 17:38:16
> @@ -416,11 +416,14 @@ doloop_modify (loop, iterations, iterati
>      }
>
>    /* Discard original jump to continue loop.  The original compare
> -     result may still be live, so it cannot be discarded explicitly.  */
> +     result may still be live, so it cannot be discarded explicitly.
> +     Don't delete too much, increment the use count of the target label. 
> */ +  LABEL_NUSES (JUMP_LABEL (jump_insn))++;
>    delete_insn (jump_insn);
> +  LABEL_NUSES (JUMP_LABEL (jump_insn))--;
>
> -  /* Emit the label that will delimit the start of the loop.  */
> -  emit_label_after (start_label, loop->start);
> +  /* Emit the label that will delimit the top of the loop.  */
> +  emit_label_after (start_label, loop->top);
>    LABEL_NUSES (start_label)++;
>
>    counter_reg = XEXP (condition, 0);

The patch needs a small refinement, but then passes the bootstrap&testsuite 
and fixes the openssl miscompilation. On to fixing the next openssl 
miscompilation :-(.

Franz.

	* doloop.c (doloop_modify): Prevent delete_insn() from deleting too much.
	Prefer loop->top over loop->start as target for the new JUMP insn.

Index: gcc/doloop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doloop.c,v
retrieving revision 1.2
diff -u -p -r1.2 doloop.c
--- doloop.c	2000/08/14 20:55:11	1.2
+++ doloop.c	2000/09/24 22:00:04
@@ -416,11 +416,14 @@ doloop_modify (loop, iterations, iterati
     }
 
   /* Discard original jump to continue loop.  The original compare
-     result may still be live, so it cannot be discarded explicitly.  */
+     result may still be live, so it cannot be discarded explicitly.
+     Don't delete too much, increment the use count of the target label.  */
+  LABEL_NUSES (JUMP_LABEL (jump_insn))++;
   delete_insn (jump_insn);
+  LABEL_NUSES (JUMP_LABEL (jump_insn))--;
 
-  /* Emit the label that will delimit the start of the loop.  */
-  emit_label_after (start_label, loop->start);
+  /* Emit the label that will delimit the top of the loop.  */
+  emit_label_after (start_label, loop->top ? loop->top : loop->start);
   LABEL_NUSES (start_label)++;
 
   counter_reg = XEXP (condition, 0);
Index: gcc/doloop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doloop.c,v
retrieving revision 1.2
diff -u -p -r1.2 doloop.c
--- doloop.c	2000/08/14 20:55:11	1.2
+++ doloop.c	2000/09/24 22:00:04
@@ -416,11 +416,14 @@ doloop_modify (loop, iterations, iterati
     }
 
   /* Discard original jump to continue loop.  The original compare
-     result may still be live, so it cannot be discarded explicitly.  */
+     result may still be live, so it cannot be discarded explicitly.
+     Don't delete too much, increment the use count of the target label.  */
+  LABEL_NUSES (JUMP_LABEL (jump_insn))++;
   delete_insn (jump_insn);
+  LABEL_NUSES (JUMP_LABEL (jump_insn))--;
 
-  /* Emit the label that will delimit the start of the loop.  */
-  emit_label_after (start_label, loop->start);
+  /* Emit the label that will delimit the top of the loop.  */
+  emit_label_after (start_label, loop->top ? loop->top : loop->start);
   LABEL_NUSES (start_label)++;
 
   counter_reg = XEXP (condition, 0);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]