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]

[RFC] rs6000 rtx_costs


	Appended is my preliminary attempt to convert rs6000 rtx_costs to
recursively descend the insn.  It probably has some typos, but I'm more
interested in feedback about the basic logic.

Thanks, David


Index: rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.670
diff -c -p -r1.670 rs6000.c
*** rs6000.c	20 Jul 2004 07:27:13 -0000	1.670
--- rs6000.c	26 Jul 2004 00:00:43 -0000
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 16506,16517 ****
        /* On the RS/6000, if it is valid in the insn, it is free.
  	 So this always returns 0.  */
      case CONST_INT:
      case CONST:
      case LABEL_REF:
      case SYMBOL_REF:
!     case CONST_DOUBLE:
!     case HIGH:
!       *total = 0;
        return true;
  
      case PLUS:
--- 16522,16577 ----
        /* On the RS/6000, if it is valid in the insn, it is free.
  	 So this always returns 0.  */
      case CONST_INT:
+       if (x == CONST0_RTX (GET_MODE (x))
+ 	  || (outer_code == PLUS && add_operand (x, VOIDmode))
+ 	  || (outer_code == MINUS && add_operand (x, VOIDmode))
+ 	  || (outer_code == AND
+ 	      && (logical_operand (x, VOIDmode)) || mask_operand (x, VOIDmode))
+ 	  || (outer_code == IOR && logical_operand (x, VOIDmode))
+ 	  || (outer_code == XOR && logical_operand (x, VOIDmode)))
+ 	{
+ 	  *total = 0;
+ 	  return true;
+ 	}
+       else if ((outer_code == PLUS
+ 		&& reg_or_add_cint64_operand (x, VOIDmode))
+ 	       || (outer_code == MINUS
+ 		   && reg_or_sub_cint64_operand (x, VOIDmode))
+ 	       || (outer_code == IOR
+ 		   && reg_or_logical_cint_operand (x, VOIDmode))
+ 	       || (outer_code == XOR
+ 		   && reg_or_logical_cint_operand (x, VOIDmode)))
+ 	{
+ 	  *total = COSTS_N_INSNS (1);
+ 	  return true;
+ 	}
+       /* FALLTHRU */
+ 
+     case CONST_DOUBLE:
+       if (x == CONST0_RTX (GET_MODE (x))
+ 	  || (outer_code == AND
+ 	      && (logical_operand (x, VOIDmode)) || mask_operand (x, VOIDmode))
+ 	  || (outer_code == IOR && logical_operand (x, VOIDmode))
+ 	  || (outer_code == XOR && logical_operand (x, VOIDmode)))
+ 	*total = 0;
+       else if ((outer_code == IOR
+ 		&& reg_or_logical_cint_operand (x, VOIDmode))
+ 	       || (outer_code == XOR
+ 		   && reg_or_logical_cint_operand (x, VOIDmode)))
+ 	*total = COSTS_N_INSNS (1);
+       else
+ 	*total = COSTS_N_INSNS (2);
+       return true;
+ 
      case CONST:
+     case HIGH:
      case LABEL_REF:
      case SYMBOL_REF:
!     case MEM:
!       /* When optimizing for size, MEM should be slightly more expensive
! 	 than generating address, e.g., (plus (reg) (const)).
!          L1 cache latecy is about two instructions.  */
!       *total = optimize_size ? COSTS_N_INSNS (1) + 1 : COSTS_N_INSNS (2);
        return true;
  
      case PLUS:
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 16528,16540 ****
  	  *total += COSTS_N_INSNS (1);
  	}
        else
! 	*total = ((GET_CODE (XEXP (x, 1)) == CONST_INT
! 		  && ((unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1))
! 						+ 0x8000) >= 0x10000)
! 		  && ((INTVAL (XEXP (x, 1)) & 0xffff) != 0))
! 		 ? COSTS_N_INSNS (2)
! 		 : COSTS_N_INSNS (1));
!       return true;
  
      case MINUS:
        if (mode == DFmode)
--- 16588,16595 ----
  	  *total += COSTS_N_INSNS (1);
  	}
        else
! 	*total = COSTS_N_INSNS (1);
!       return false;
  
      case MINUS:
        if (mode == DFmode)
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 16551,16567 ****
  	}
        else
          *total = COSTS_N_INSNS (1);
!       return true;
! 
!     case AND:
!     case IOR:
!     case XOR:
!       *total = ((GET_CODE (XEXP (x, 1)) == CONST_INT
! 		 && (INTVAL (XEXP (x, 1)) & (~ (HOST_WIDE_INT) 0xffff)) != 0
! 		 && ((INTVAL (XEXP (x, 1)) & 0xffff) != 0))
! 		? COSTS_N_INSNS (2)
! 		: COSTS_N_INSNS (1));
!       return true;
  
      case MULT:
        if (GET_CODE (XEXP (x, 1)) == CONST_INT)
--- 16606,16612 ----
  	}
        else
          *total = COSTS_N_INSNS (1);
!       return false;
  
      case MULT:
        if (GET_CODE (XEXP (x, 1)) == CONST_INT)
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 16610,16638 ****
        *total = COSTS_N_INSNS (4);
        return true;
  
-     case NEG:
-     case ABS:
-       if (FLOAT_MODE_P (mode))
- 	*total = rs6000_cost->fp;
-       else
- 	*total = COSTS_N_INSNS (1);
-       return true;
- 
-     case MEM:
-       /* MEM should be slightly more expensive than (plus (reg) (const)).  */
-       *total = COSTS_N_INSNS (1) + 1;
-       return true;
- 
      case NOT:
      case SIGN_EXTEND:
      case ZERO_EXTEND:
-     case COMPARE:
        *total = COSTS_N_INSNS (1);
!       break;
  
      case FLOAT_TRUNCATE:
        *total = rs6000_cost->fp;
!       return true;
  
      case UNSPEC:
        switch (XINT (x, 1))
--- 16655,16699 ----
        *total = COSTS_N_INSNS (4);
        return true;
  
      case NOT:
+       if (outer_code == AND || outer_code == IOR || outer_code == XOR)
+ 	{
+ 	  *total = 0;
+ 	  return true;
+ 	}
+       /* FALLTHRU */
+ 
+     case AND:
+     case IOR:
+     case XOR:
+     case ASHIFT:
+     case ASHIFTRT:
+     case LSHIFTRT:
+     case ROTATE:
+     case ROTATERT:
      case SIGN_EXTEND:
      case ZERO_EXTEND:
        *total = COSTS_N_INSNS (1);
!       return false;
  
+     case COMPARE:
+     case NEG:
+     case ABS:
+       if (!FLOAT_MODE_P (mode))
+ 	{
+ 	  *total = COSTS_N_INSNS (1);
+ 	  return false;
+ 	}
+       /* FALLTHRU */
+ 
+     case FLOAT:
+     case UNSIGNED_FLOAT:
+     case FIX:
+     case UNSIGNED_FIX:
+     case FLOAT_EXTEND:
      case FLOAT_TRUNCATE:
        *total = rs6000_cost->fp;
!       return false;
  
      case UNSPEC:
        switch (XINT (x, 1))
*************** rs6000_rtx_costs (rtx x, int code, int o
*** 16653,16658 ****
--- 16714,16726 ----
  	  *total = COSTS_N_INSNS (1);
  	  return true;
  	}
+       else if (FLOAT_MODE_P (x)
+ 	       && TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS)
+ 	{
+ 	  *total = rs6000_cost->fp;
+ 	  return false;
+ 	}
+ 
        break;
  
      default:


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