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]

i386 fp branches tweek



Hi
This patch is handy to make gcc trigger the bug I've just fixed in reg-stack :)
But it also improves code by splitting the fcomi based branches early and
allowing gcc to CSE compares.

Pá úno 16 19:48:18 CET 2001  Jan Hubicka  <jh@suse.cz>

	* i386.md (jmp_fp_* splitters): Update calls of split_fp_branch.
	* i386.c (ix86_expand_branch): Early split the simple fcomi cases.
	(split_fp_branch): Accept parameter "CODE" instead of "COMPARISON"
	* i386-protos.h: Update prototype.

*** i386.md.old	Fri Feb 16 18:33:44 2001
--- i386.md	Fri Feb 16 18:34:23 2001
***************
*** 9667,9673 ****
    [(const_int 0)]
    "
  {
!   ix86_split_fp_branch (operands[0], operands[1], operands[2],
  			operands[3], operands[4], NULL_RTX);
    DONE;
  }")
--- 9667,9673 ----
    [(const_int 0)]
    "
  {
!   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
  			operands[3], operands[4], NULL_RTX);
    DONE;
  }")
***************
*** 9689,9695 ****
  	  (match_dup 4)))]
    "
  {
!   ix86_split_fp_branch (operands[0], operands[1], operands[2],
  			operands[3], operands[4], operands[5]);
    DONE;
  }")
--- 9689,9695 ----
  	  (match_dup 4)))]
    "
  {
!   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
  			operands[3], operands[4], operands[5]);
    DONE;
  }")
***************
*** 12999,13005 ****
  {
    emit_insn (gen_rtx_TRAP_IF (VOIDmode,
  			      ix86_expand_compare (GET_CODE (operands[0]),
! 						   NULL_RTX, NULL_RTX),
  			      operands[1]));
    DONE;
  }")
--- 12999,13005 ----
  {
    emit_insn (gen_rtx_TRAP_IF (VOIDmode,
  			      ix86_expand_compare (GET_CODE (operands[0]),
! 						   NULL, NULL),
  			      operands[1]));
    DONE;
  }")
*** i386.c.old	Fri Feb 16 18:31:28 2001
--- i386.c	Fri Feb 16 18:36:32 2001
*************** ix86_expand_branch (code, label)
*** 5274,5279 ****
--- 5274,5295 ----
  	code = ix86_prepare_fp_compare_args (code, &ix86_compare_op0,
  					     &ix86_compare_op1);
  
+ 	/* In case the conditional results in single branch using fcomi, it
+ 	   is better to split it early to allow CSE and other optimizations
+ 	   over flags.  */
+ 	if (ix86_use_fcomi_compare (code))
+ 	  {
+ 	    enum rtx_code first_code, second_code, bypass_code;
+ 	    ix86_fp_comparison_codes (code, &bypass_code, &first_code, &second_code);
+ 	    if (second_code == NIL && bypass_code == NIL)
+ 	      {
+ 		ix86_split_fp_branch (code, ix86_compare_op0, ix86_compare_op1,
+ 				      gen_rtx_LABEL_REF (VOIDmode, label),
+ 				      pc_rtx, NULL_RTX);
+ 		return;
+ 	      }
+ 	  }
+ 
  	tmp = gen_rtx_fmt_ee (code, VOIDmode,
  			      ix86_compare_op0, ix86_compare_op1);
  	tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
*************** ix86_expand_branch (code, label)
*** 5414,5425 ****
  
  /* Split branch based on floating point condition.  */
  void
! ix86_split_fp_branch (condition, op1, op2, target1, target2, tmp)
!      rtx condition, op1, op2, target1, target2, tmp;
  {
    rtx second, bypass;
    rtx label = NULL_RTX;
!   enum rtx_code code = GET_CODE (condition);
  
    if (target2 != pc_rtx)
      {
--- 5430,5442 ----
  
  /* Split branch based on floating point condition.  */
  void
! ix86_split_fp_branch (code, op1, op2, target1, target2, tmp)
!      enum rtx_code code;
!      rtx op1, op2, target1, target2, tmp;
  {
    rtx second, bypass;
    rtx label = NULL_RTX;
!   rtx condition;
  
    if (target2 != pc_rtx)
      {
*** i386-protos.h.old	Fri Feb 16 18:33:22 2001
--- i386-protos.h	Fri Feb 16 18:33:33 2001
*************** extern enum machine_mode ix86_fp_compare
*** 129,135 ****
  
  extern rtx ix86_force_to_memory PARAMS ((enum machine_mode, rtx));
  extern void ix86_free_from_memory PARAMS ((enum machine_mode));
! extern void ix86_split_fp_branch PARAMS ((rtx, rtx, rtx, rtx, rtx, rtx));
  extern int ix86_hard_regno_mode_ok PARAMS ((int, enum machine_mode));
  extern int ix86_register_move_cost PARAMS ((enum machine_mode, enum reg_class,
  					    enum reg_class));
--- 129,136 ----
  
  extern rtx ix86_force_to_memory PARAMS ((enum machine_mode, rtx));
  extern void ix86_free_from_memory PARAMS ((enum machine_mode));
! extern void ix86_split_fp_branch PARAMS ((enum rtx_code, rtx, rtx, rtx, rtx,
! 					  rtx));
  extern int ix86_hard_regno_mode_ok PARAMS ((int, enum machine_mode));
  extern int ix86_register_move_cost PARAMS ((enum machine_mode, enum reg_class,
  					    enum reg_class));


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