[PATCH] doloop_optimize miscompiles openssl

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Sun Sep 24 15:07:00 GMT 2000


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);


More information about the Gcc-patches mailing list