trivial swap_commutative_operands_p fix

Jan Hubicka jh@suse.cz
Mon Jun 4 08:08:00 GMT 2001


Hi,
my patches from May 17th caused slowdowns in spec95 nightly testing, even when
they was expected to fix the slowdowns made by latest gcse changes.
It took me a while to sort out what really happenned and why, but after few
wrong shorts, I believe I've got it.  The purpose is simple.

swap_commutative_operands function introduced by my change improperly
handles complex expression.  The last rule says that "Complex expressions
should be the first." but in fact increases priority of objects.  This
patch fixes it.
It is not one liner, since I need to renumber other priorities, but still
I believe it is simple enought to fall into "obvious bugfix" category.

I apologize for the code quality regressions I've caused, but just the fact
that no one has asked me about that suggests, that we need more of code quality
testing in gcc development.

Honza

Mon Jun  4 17:03:44 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* rtlanal.c (operand_preference): Fix preference for objects.
Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtlanal.c,v
retrieving revision 1.97
diff -c -3 -p -r1.97 rtlanal.c
*** rtlanal.c	2001/06/04 14:52:14	1.97
--- rtlanal.c	2001/06/04 15:02:00
*************** operand_preference (op)
*** 2515,2530 ****
  {
    /* Constants always come the second operand.  Prefer "nice" constants.  */
    if (GET_CODE (op) == CONST_INT)
!     return -4;
    if (GET_CODE (op) == CONST_DOUBLE)
!     return -3;
    if (CONSTANT_P (op))
!     return -2;
  
    /* SUBREGs of objects should come second.  */
    if (GET_CODE (op) == SUBREG
        && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op))) == 'o')
!     return -1;
  
    /* If only one operand is a `neg', `not',
      `mult', `plus', or `minus' expression, it will be the first
--- 2515,2530 ----
  {
    /* Constants always come the second operand.  Prefer "nice" constants.  */
    if (GET_CODE (op) == CONST_INT)
!     return -5;
    if (GET_CODE (op) == CONST_DOUBLE)
!     return -4;
    if (CONSTANT_P (op))
!     return -3;
  
    /* SUBREGs of objects should come second.  */
    if (GET_CODE (op) == SUBREG
        && GET_RTX_CLASS (GET_CODE (SUBREG_REG (op))) == 'o')
!     return -2;
  
    /* If only one operand is a `neg', `not',
      `mult', `plus', or `minus' expression, it will be the first
*************** operand_preference (op)
*** 2534,2542 ****
        || GET_CODE (op) == MINUS)
      return 2;
  
!   /* Complex expressions should be the first.  */
    if (GET_RTX_CLASS (GET_CODE (op)) == 'o')
!     return 1;
    return 0;
  }
  
--- 2534,2543 ----
        || GET_CODE (op) == MINUS)
      return 2;
  
!   /* Complex expressions should be the first, so decrease priority
!      of objects.  */
    if (GET_RTX_CLASS (GET_CODE (op)) == 'o')
!     return -1;
    return 0;
  }
  



More information about the Gcc-patches mailing list