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]

[Comitted] Privatize do_jump_by_parts_greater_rtx


The following patch is a further clean-up of the middle-end's RTL
expansion of conditional jumps enabled by the recent restructuring.
Now taht do_compare_rtx_and_jump optimizes multi-word compares itself,
it turns out that all uses of do_jump_by_parts_greater_rtx outside of
dojump.c can be eliminated by simply calling do_compare_rtx_and_jump.

The following patch has been tested on x86_64-unknown-linux-gnu with
a full "make bootstrap", all default langauges, and regression checked
with a top-level "make -k check" with no new failures.

Committed to mainline as revision 110954.



2006-02-13  Roger Sayle  <roger@eyesopen.com>

	* optabs.c (expand_abs): Don't call do_jump_by_parts_greater_rtx
	directly, instead let do_compare_rtx_and_jump handle this for us.
	* expr.c (expand_expr_real_1): Likewise.
	* dojump.c (do_jump_by_parts_greater_rtx): Make static.  Move
	before do_jump_by_parts_greater.
	(do_jump_by_parts_greater): Move after do_jump_by_parts_greater_rtx.
	* expr.h (do_jump_by_parts_greater_rtx): Delete prototype.


Index: optabs.c
===================================================================
*** optabs.c	(revision 110908)
--- optabs.c	(working copy)
*************** expand_abs (enum machine_mode mode, rtx
*** 2898,2912 ****
    emit_move_insn (target, op0);
    NO_DEFER_POP;

!   /* If this mode is an integer too wide to compare properly,
!      compare word by word.  Rely on CSE to optimize constant cases.  */
!   if (GET_MODE_CLASS (mode) == MODE_INT
!       && ! can_compare_p (GE, mode, ccp_jump))
!     do_jump_by_parts_greater_rtx (mode, 0, target, const0_rtx,
! 				  NULL_RTX, op1);
!   else
!     do_compare_rtx_and_jump (target, CONST0_RTX (mode), GE, 0, mode,
! 			     NULL_RTX, NULL_RTX, op1);

    op0 = expand_unop (mode, result_unsignedp ? neg_optab : negv_optab,
                       target, target, 0);
--- 2898,2905 ----
    emit_move_insn (target, op0);
    NO_DEFER_POP;

!   do_compare_rtx_and_jump (target, CONST0_RTX (mode), GE, 0, mode,
! 			   NULL_RTX, NULL_RTX, op1);

    op0 = expand_unop (mode, result_unsignedp ? neg_optab : negv_optab,
                       target, target, 0);
Index: expr.c
===================================================================
*** expr.c	(revision 110908)
--- expr.c	(working copy)
*************** expand_expr_real_1 (tree exp, rtx target
*** 8184,8207 ****
  	  emit_move_insn (target, op0);

  	temp = gen_label_rtx ();
!
! 	/* If this mode is an integer too wide to compare properly,
! 	   compare word by word.  Rely on cse to optimize constant cases.  */
! 	if (GET_MODE_CLASS (mode) == MODE_INT
! 	    && ! can_compare_p (GE, mode, ccp_jump))
! 	  {
! 	    if (code == MAX_EXPR)
! 	      do_jump_by_parts_greater_rtx (mode, unsignedp, target, op1,
! 					    NULL_RTX, temp);
! 	    else
! 	      do_jump_by_parts_greater_rtx (mode, unsignedp, op1, target,
! 					    NULL_RTX, temp);
! 	  }
! 	else
! 	  {
! 	    do_compare_rtx_and_jump (target, cmpop1, comparison_code,
! 				     unsignedp, mode, NULL_RTX, NULL_RTX, temp);
! 	  }
        }
        emit_move_insn (target, op1);
        emit_label (temp);
--- 8184,8191 ----
  	  emit_move_insn (target, op0);

  	temp = gen_label_rtx ();
! 	do_compare_rtx_and_jump (target, cmpop1, comparison_code,
! 				 unsignedp, mode, NULL_RTX, NULL_RTX, temp);
        }
        emit_move_insn (target, op1);
        emit_label (temp);
Index: dojump.c
===================================================================
*** dojump.c	(revision 110908)
--- dojump.c	(working copy)
*************** do_jump (tree exp, rtx if_false_label, r
*** 609,637 ****
      }
  }

- /* Given a comparison expression EXP for values too wide to be compared
-    with one insn, test the comparison and jump to the appropriate label.
-    The code of EXP is ignored; we always test GT if SWAP is 0,
-    and LT if SWAP is 1.  */
-
- static void
- do_jump_by_parts_greater (tree exp, int swap, rtx if_false_label,
- 			  rtx if_true_label)
- {
-   rtx op0 = expand_normal (TREE_OPERAND (exp, swap));
-   rtx op1 = expand_normal (TREE_OPERAND (exp, !swap));
-   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
-   int unsignedp = TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
-
-   do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label,
- 				if_true_label);
- }
-
  /* Compare OP0 with OP1, word at a time, in mode MODE.
     UNSIGNEDP says to do unsigned comparison.
     Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise.  */

! void
  do_jump_by_parts_greater_rtx (enum machine_mode mode, int unsignedp, rtx op0,
  			      rtx op1, rtx if_false_label, rtx if_true_label)
  {
--- 609,619 ----
      }
  }

  /* Compare OP0 with OP1, word at a time, in mode MODE.
     UNSIGNEDP says to do unsigned comparison.
     Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise.  */

! static void
  do_jump_by_parts_greater_rtx (enum machine_mode mode, int unsignedp, rtx op0,
  			      rtx op1, rtx if_false_label, rtx if_true_label)
  {
*************** do_jump_by_parts_greater_rtx (enum machi
*** 677,682 ****
--- 659,682 ----
    if (drop_through_label)
      emit_label (drop_through_label);
  }
+
+ /* Given a comparison expression EXP for values too wide to be compared
+    with one insn, test the comparison and jump to the appropriate label.
+    The code of EXP is ignored; we always test GT if SWAP is 0,
+    and LT if SWAP is 1.  */
+
+ static void
+ do_jump_by_parts_greater (tree exp, int swap, rtx if_false_label,
+ 			  rtx if_true_label)
+ {
+   rtx op0 = expand_normal (TREE_OPERAND (exp, swap));
+   rtx op1 = expand_normal (TREE_OPERAND (exp, !swap));
+   enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
+   int unsignedp = TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
+
+   do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label,
+ 				if_true_label);
+ }

  /* Jump according to whether OP0 is 0.  We assume that OP0 has an integer
     mode, MODE, that is too wide for the available compare insns.  Either
Index: expr.h
===================================================================
*** expr.h	(revision 110908)
--- expr.h	(working copy)
*************** extern void init_all_optabs (void);
*** 743,751 ****
  /* Call this to initialize an optab function entry.  */
  extern rtx init_one_libfunc (const char *);

- extern void do_jump_by_parts_greater_rtx (enum machine_mode, int, rtx, rtx,
- 					  rtx, rtx);
-
  extern int vector_mode_valid_p (enum machine_mode);

  #endif /* GCC_EXPR_H */
--- 743,748 ----


Roger
--


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