Thumb: pevent extraneous jumps around constant tables

Nick Clifton nickc@cygnus.com
Tue Feb 8 15:07:00 GMT 2000


Hi Richard,

  Below is a small patch to prevent the Thumb machine dependent
  reoranisation code from emitting unecessary jump instructions after
  the epilogue.  This happens when a constant table is needed for a
  small function.  (For example Proc_5 in the Dhrystone benchmark).

  Without this patch code like this would be produced:

Proc_5:
	ldr	r1, .L57
	mov	r0, #65
	strb	r0, [r1]
	ldr	r1, .L57+4
	mov	r0, #0
	str	r0, [r1]
	bx	lr
	b	.L56

  The final branch is unnecessary.  After applying the patch this
  instruction is no longer generated.

  The patch works by detecting if the code is about to insert a jump
  after the epilogue insn, and if so, preventing the jump from being
  generated.

  OK to apply ?

Cheers
	Nick


2000-02-08  Nick Clifton  <nickc@cygnus.com>

	* config/arm/thumb.c (find_barrier): Do not emit a jump insn
	if we have reached the epilogue.

Index: config/arm/thumb.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/arm/thumb.c,v
retrieving revision 1.15
diff -p -r1.15 thumb.c
*** thumb.c	1999/11/02 17:06:24	1.15
--- thumb.c	2000/02/08 22:59:41
*************** find_barrier (from)
*** 558,564 ****
  	 || GET_CODE (from) == CODE_LABEL)
      from = PREV_INSN (from);
    
-   from = emit_jump_insn_after (gen_jump (label), from);
-   JUMP_LABEL (from) = label;
    found_barrier = emit_barrier_after (from);
    emit_label_after (label, found_barrier);
--- 558,572 ----
  	 || GET_CODE (from) == CODE_LABEL)
      from = PREV_INSN (from);
+ 
+   /* If we have reached the epilogue then there is
+      no need to emit a jump around the barrier.  */
+   if (! (GET_CODE (from) == INSN
+ 	 && GET_CODE (PATTERN (from)) == UNSPEC_VOLATILE
+ 	 && XINT (PATTERN (from), 1) == 1))
+     {
+       from = emit_jump_insn_after (gen_jump (label), from);
+       JUMP_LABEL (from) = label;
+     }
    
    found_barrier = emit_barrier_after (from);
    emit_label_after (label, found_barrier);


More information about the Gcc-patches mailing list