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]

more uses for swap_commutative_operands_p


Hi,
I don't think I've found all relevant places, but as an start this should
be enought.
bootstrap completted; make check is in progress.

Honza

Thu May 17 21:42:27 CEST 2001  Jan Hubicka  <jh@suse.cz>

	* combine.c (combine_simplify_rtx): Use swap_commutative_operands_p.
	(gen_binary): Likewise.
	* optabs.c (emit_cmp_and_jump_insns, emit_conditional_move): Likewise.
	* simplify-rtx.c (simplify_gen_binary, simplify_gen_relational): Likewise.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.200
diff -c -3 -p -r1.200 combine.c
*** combine.c	2001/05/17 15:00:34	1.200
--- combine.c	2001/05/17 19:40:09
*************** combine_simplify_rtx (x, op0_mode, last,
*** 3514,3525 ****
    /* If this is a commutative operation, put a constant last and a complex
       expression first.  We don't need to do this for comparisons here.  */
    if (GET_RTX_CLASS (code) == 'c'
!       && ((CONSTANT_P (XEXP (x, 0)) && GET_CODE (XEXP (x, 1)) != CONST_INT)
! 	  || (GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == 'o'
! 	      && GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) != 'o')
! 	  || (GET_CODE (XEXP (x, 0)) == SUBREG
! 	      && GET_RTX_CLASS (GET_CODE (SUBREG_REG (XEXP (x, 0)))) == 'o'
! 	      && GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) != 'o')))
      {
        temp = XEXP (x, 0);
        SUBST (XEXP (x, 0), XEXP (x, 1));
--- 3514,3520 ----
    /* If this is a commutative operation, put a constant last and a complex
       expression first.  We don't need to do this for comparisons here.  */
    if (GET_RTX_CLASS (code) == 'c'
!       && swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1)))
      {
        temp = XEXP (x, 0);
        SUBST (XEXP (x, 0), XEXP (x, 1));
*************** gen_binary (code, mode, op0, op1)
*** 9818,9829 ****
  
    /* Put complex operands first and constants second.  */
    if (GET_RTX_CLASS (code) == 'c'
!       && ((CONSTANT_P (op0) && GET_CODE (op1) != CONST_INT)
! 	  || (GET_RTX_CLASS (GET_CODE (op0)) == 'o'
! 	      && GET_RTX_CLASS (GET_CODE (op1)) != 'o')
! 	  || (GET_CODE (op0) == SUBREG
! 	      && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op0))) == 'o'
! 	      && GET_RTX_CLASS (GET_CODE (op1)) != 'o')))
      return gen_rtx_fmt_ee (code, mode, op1, op0);
  
    /* If we are turning off bits already known off in OP0, we need not do
--- 9813,9819 ----
  
    /* Put complex operands first and constants second.  */
    if (GET_RTX_CLASS (code) == 'c'
!       && swap_commutative_operands_p (op0, op1))
      return gen_rtx_fmt_ee (code, mode, op1, op0);
  
    /* If we are turning off bits already known off in OP0, we need not do
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/optabs.c,v
retrieving revision 1.96
diff -c -3 -p -r1.96 optabs.c
*** optabs.c	2001/05/11 15:28:40	1.96
--- optabs.c	2001/05/17 19:40:12
*************** emit_cmp_and_jump_insns (x, y, compariso
*** 3290,3297 ****
    rtx op0;
    rtx op1;
  	  
!   if ((CONSTANT_P (x) && ! CONSTANT_P (y))
!       || (GET_CODE (x) == CONST_INT && GET_CODE (y) != CONST_INT))
      {
        /* Swap operands and condition to ensure canonical RTL.  */
        op0 = y;
--- 3290,3296 ----
    rtx op0;
    rtx op1;
  	  
!   if (swap_commutative_operands_p (x, y))
      {
        /* Swap operands and condition to ensure canonical RTL.  */
        op0 = y;
*************** emit_conditional_move (target, code, op0
*** 3609,3620 ****
  {
    rtx tem, subtarget, comparison, insn;
    enum insn_code icode;
  
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if ((CONSTANT_P (op0) && ! CONSTANT_P (op1))
!       || (GET_CODE (op0) == CONST_INT && GET_CODE (op1) != CONST_INT))
      {
        tem = op0;
        op0 = op1;
--- 3608,3619 ----
  {
    rtx tem, subtarget, comparison, insn;
    enum insn_code icode;
+   enum rtx_code reversed;
  
    /* If one operand is constant, make it the second one.  Only do this
       if the other operand is not constant as well.  */
  
!   if (swap_commutative_operands_p (op0, op1))
      {
        tem = op0;
        op0 = op1;
*************** emit_conditional_move (target, code, op0
*** 3633,3648 ****
    if (cmode == VOIDmode)
      cmode = GET_MODE (op0);
  
!   if (((CONSTANT_P (op2) && ! CONSTANT_P (op3))
!        || (GET_CODE (op2) == CONST_INT && GET_CODE (op3) != CONST_INT))
!       && (GET_MODE_CLASS (GET_MODE (op1)) != MODE_FLOAT
! 	  || TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT 
! 	  || flag_unsafe_math_optimizations))
      {
        tem = op2;
        op2 = op3;
        op3 = tem;
!       code = reverse_condition (code);
      }
  
    if (mode == VOIDmode)
--- 3632,3645 ----
    if (cmode == VOIDmode)
      cmode = GET_MODE (op0);
  
!   if (swap_commutative_operands_p (op2, op3)
!       && ((reversed = reversible_comparison_code_parts (code, op0, op1, NULL))
!           != UNKNOWN))
      {
        tem = op2;
        op2 = op3;
        op3 = tem;
!       code = reversed;
      }
  
    if (mode == VOIDmode)
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.52
diff -c -3 -p -r1.52 simplify-rtx.c
*** simplify-rtx.c	2001/05/17 18:46:58	1.52
--- simplify-rtx.c	2001/05/17 19:40:14
*************** simplify_gen_binary (code, mode, op0, op
*** 113,124 ****
  
    /* Put complex operands first and constants second if commutative.  */
    if (GET_RTX_CLASS (code) == 'c'
!       && ((CONSTANT_P (op0) && GET_CODE (op1) != CONST_INT)
! 	  || (GET_RTX_CLASS (GET_CODE (op0)) == 'o'
! 	      && GET_RTX_CLASS (GET_CODE (op1)) != 'o')
! 	  || (GET_CODE (op0) == SUBREG
! 	      && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op0))) == 'o'
! 	      && GET_RTX_CLASS (GET_CODE (op1)) != 'o')))
      tem = op0, op0 = op1, op1 = tem;
  
    /* If this simplifies, do it.  */
--- 113,119 ----
  
    /* Put complex operands first and constants second if commutative.  */
    if (GET_RTX_CLASS (code) == 'c'
!       && swap_commutative_operands_p (op0, op1))
      tem = op0, op0 = op1, op1 = tem;
  
    /* If this simplifies, do it.  */
*************** simplify_gen_relational (code, mode, cmp
*** 194,205 ****
      return tem;
  
    /* Put complex operands first and constants second.  */
!   if ((CONSTANT_P (op0) && GET_CODE (op1) != CONST_INT)
!       || (GET_RTX_CLASS (GET_CODE (op0)) == 'o'
! 	  && GET_RTX_CLASS (GET_CODE (op1)) != 'o')
!       || (GET_CODE (op0) == SUBREG
! 	  && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op0))) == 'o'
! 	  && GET_RTX_CLASS (GET_CODE (op1)) != 'o'))
      tem = op0, op0 = op1, op1 = tem, code = swap_condition (code);
  
    return gen_rtx_fmt_ee (code, mode, op0, op1);
--- 189,195 ----
      return tem;
  
    /* Put complex operands first and constants second.  */
!   if (swap_commutative_operands_p (op0, op1))
      tem = op0, op0 = op1, op1 = tem, code = swap_condition (code);
  
    return gen_rtx_fmt_ee (code, mode, op0, op1);


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