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]
Other format: [Raw text]

Patch: Fix branch lengths on bfin


This patch by Jie Zhang fixes our branch length calculations in one case.

Committed on mainline (as this shouldn't interfere with rth's proposed slush) and the 4.0 branch (although it's not strictly a regression since there is no previous gcc release with the Blackfin port).


Bernd
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.8860
diff -c -p -r2.8860 ChangeLog
*** ChangeLog	19 May 2005 06:47:44 -0000	2.8860
--- ChangeLog	19 May 2005 08:37:03 -0000
***************
*** 1,3 ****
--- 1,11 ----
+ 2005-05-18  Jie Zhang  <jie.zhang@analog.com>
+             Bernd Schmidt  <bernd.schmidt@analog.com>
+ 
+ 	* config/bfin/bfin.c (branch_dest): Add comment why it's
+ 	necessary.
+ 	* config/bfin/bfin.md (attr "length" default): Change the offset of
+ 	forward conditional branch of length 4 from 4096 to 4092.
+ 
  2005-05-19  Jan Beulich  <jbeulich@novell.com>
  
  	* unwind-compat.c: Include tconfig.h and tsystem.h.
Index: config/bfin/bfin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/bfin.c,v
retrieving revision 1.6
diff -c -p -r1.6 bfin.c
*** config/bfin/bfin.c	2 May 2005 14:29:43 -0000	1.6
--- config/bfin/bfin.c	19 May 2005 08:37:05 -0000
*************** override_options (void)
*** 1751,1757 ****
    flag_schedule_insns = 0;
  }
  
! /* Return the destination address of BRANCH.  */
  
  static int
  branch_dest (rtx branch)
--- 1751,1760 ----
    flag_schedule_insns = 0;
  }
  
! /* Return the destination address of BRANCH.
!    We need to use this instead of get_attr_length, because the
!    cbranch_with_nops pattern conservatively sets its length to 6, and
!    we still prefer to use shorter sequences.  */
  
  static int
  branch_dest (rtx branch)
Index: config/bfin/bfin.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/bfin/bfin.md,v
retrieving revision 1.3
diff -c -p -r1.3 bfin.md
*** config/bfin/bfin.md	17 May 2005 13:10:26 -0000	1.3
--- config/bfin/bfin.md	19 May 2005 08:37:05 -0000
***************
*** 173,179 ****
  ;;;   if cc jmp; jump.[sl] offset
  ;;;   offset of jump.[sl] is from the jump instruction but
  ;;;     gcc calculates length from the if cc jmp instruction
! ;;;     hence our range is (-4094, 4096) instead of (-4096, 4094) for a br
  ;;;
  ;;; The way the (pc) rtx works in these calculations is somewhat odd;
  ;;; for backward branches it's the address of the current instruction,
--- 173,181 ----
  ;;;   if cc jmp; jump.[sl] offset
  ;;;   offset of jump.[sl] is from the jump instruction but
  ;;;     gcc calculates length from the if cc jmp instruction
! ;;;     furthermore gcc takes the end address of the branch instruction
! ;;;     as (pc) for a forward branch
! ;;;     hence our range is (-4094, 4092) instead of (-4096, 4094) for a br
  ;;;
  ;;; The way the (pc) rtx works in these calculations is somewhat odd;
  ;;; for backward branches it's the address of the current instruction,
***************
*** 210,216 ****
  	            (ge (minus (match_dup 3) (pc)) (const_int -1024)))
  		  (const_int 2)
  		(and
! 	            (le (minus (match_dup 3) (pc)) (const_int 4096))
  	            (ge (minus (match_dup 3) (pc)) (const_int -4094)))
  		  (const_int 4)]
  	       (const_int 6))
--- 212,218 ----
  	            (ge (minus (match_dup 3) (pc)) (const_int -1024)))
  		  (const_int 2)
  		(and
! 	            (le (minus (match_dup 3) (pc)) (const_int 4092))
  	            (ge (minus (match_dup 3) (pc)) (const_int -4094)))
  		  (const_int 4)]
  	       (const_int 6))

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