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, committed] rs6000_rtx_costs PR target/16800


	This patch further improves rs6000_rtx_costs for SCC instructions
and should resolve PR target/16800.  It also distinguishes between
CONST_INT costs for SImode and DImode.

Bootstrapped on powerpc-ibm-aix5.2.0.0.

David


	PR target/16800
	* config/rs6000/rs6000.c (rs6000_rtx_costs): Improve accuracy of
	EQ, GTU, and LTU costs.  Add costs for GT, LT, and UNORDERED.
	Distinguish between SImode and DImode CONST_INT.

Index: rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.756
diff -c -p -r1.756 rs6000.c
*** rs6000.c	27 Nov 2004 22:51:43 -0000	1.756
--- rs6000.c	27 Nov 2004 22:52:51 -0000
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 18050,18065 ****
  	    || outer_code == MINUS)
  	   && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'I')
  	       || CONST_OK_FOR_LETTER_P (INTVAL (x), 'L')))
- 	  || ((outer_code == IOR || outer_code == XOR)
- 	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
- 		  || CONST_OK_FOR_LETTER_P (INTVAL (x), 'L')))
- 	  || ((outer_code == DIV || outer_code == UDIV
- 	       || outer_code == MOD || outer_code == UMOD)
- 	      && exact_log2 (INTVAL (x)) >= 0)
  	  || (outer_code == AND
  	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
! 		  || CONST_OK_FOR_LETTER_P (INTVAL (x), 'L')
  		  || mask_operand (x, VOIDmode)))
  	  || outer_code == ASHIFT
  	  || outer_code == ASHIFTRT
  	  || outer_code == LSHIFTRT
--- 18050,18064 ----
  	    || outer_code == MINUS)
  	   && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'I')
  	       || CONST_OK_FOR_LETTER_P (INTVAL (x), 'L')))
  	  || (outer_code == AND
  	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
! 		  || (CONST_OK_FOR_LETTER_P (INTVAL (x),
! 					     mode == SImode ? 'L' : 'J'))
  		  || mask_operand (x, VOIDmode)))
+ 	  || ((outer_code == IOR || outer_code == XOR)
+ 	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
+ 		  || (CONST_OK_FOR_LETTER_P (INTVAL (x),
+ 					     mode == SImode ? 'L' : 'J'))))
  	  || outer_code == ASHIFT
  	  || outer_code == ASHIFTRT
  	  || outer_code == LSHIFTRT
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 18068,18076 ****
  	  || outer_code == ZERO_EXTRACT
  	  || (outer_code == MULT
  	      && CONST_OK_FOR_LETTER_P (INTVAL (x), 'I'))
  	  || (outer_code == COMPARE
  	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'I')
! 		  || CONST_OK_FOR_LETTER_P (INTVAL (x), 'K'))))
  	{
  	  *total = 0;
  	  return true;
--- 18067,18087 ----
  	  || outer_code == ZERO_EXTRACT
  	  || (outer_code == MULT
  	      && CONST_OK_FOR_LETTER_P (INTVAL (x), 'I'))
+ 	  || ((outer_code == DIV || outer_code == UDIV
+ 	       || outer_code == MOD || outer_code == UMOD)
+ 	      && exact_log2 (INTVAL (x)) >= 0)
  	  || (outer_code == COMPARE
  	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'I')
! 		  || CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')))
! 	  || (outer_code == EQ
! 	      && (CONST_OK_FOR_LETTER_P (INTVAL (x), 'I')
! 		  || CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
! 		  || (CONST_OK_FOR_LETTER_P (INTVAL (x),
! 					     mode == SImode ? 'L' : 'J'))))
! 	  || (outer_code == GTU
! 	      && CONST_OK_FOR_LETTER_P (INTVAL (x), 'I'))
! 	  || (outer_code == LTU
! 	      && CONST_OK_FOR_LETTER_P (INTVAL (x), 'P')))
  	{
  	  *total = 0;
  	  return true;
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 18348,18373 ****
      case EQ:
      case GTU:
      case LTU:
!       if (mode == Pmode)
  	{
! 	  switch (outer_code)
  	    {
! 	    case PLUS:
! 	    case NEG:
! 	      /* PLUS or NEG already counted so only add one more.  */
! 	      *total = COSTS_N_INSNS (1);
! 	      break;
! 	    case SET:
! 	      *total = COSTS_N_INSNS (3);
! 	      break;
! 	    case COMPARE:
! 	      *total = 0;
  	      return true;
- 	    default:
- 	      break;
  	    }
! 	  return false;
  	}
  
      default:
        break;
--- 18359,18402 ----
      case EQ:
      case GTU:
      case LTU:
!       /* Carry bit requires mode == Pmode.
! 	 NEG or PLUS already counted so only add one.  */
!       if (mode == Pmode
! 	  && (outer_code == NEG || outer_code == PLUS))
! 	{
! 	  *total = COSTS_N_INSNS (1);
! 	  return true;
! 	}
!       if (outer_code == SET)
  	{
! 	  if (XEXP (x, 1) == const0_rtx)
  	    {
! 	      *total = COSTS_N_INSNS (2);
  	      return true;
  	    }
! 	  else if (mode == Pmode)
! 	    {
! 	      *total = COSTS_N_INSNS (3);
! 	      return false;
! 	    }
  	}
+       /* FALLTHRU */
+ 
+     case GT:
+     case LT:
+     case UNORDERED:
+       if (outer_code == SET && (XEXP (x, 1) == const0_rtx))
+ 	{
+ 	  *total = COSTS_N_INSNS (2);
+ 	  return true;
+ 	}
+       /* CC COMPARE.  */
+       if (outer_code == COMPARE)
+ 	{
+ 	  *total = 0;
+ 	  return true;
+ 	}
+       break;
  
      default:
        break;


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