Patchwork [MIPS,committed] Fix cost of CINS

login
register
mail settings
Submitter Richard Sandiford
Date Aug. 26, 2012, 7:19 p.m.
Message ID <87ipc531h2.fsf@talisman.home>
Download mbox | patch
Permalink /patch/180080/
State New
Headers show

Comments

Richard Sandiford - Aug. 26, 2012, 7:19 p.m.
CINS wasn't being used in -Os code because the combination didn't
seem profitable enough.

Tested on mipsisa64-elf, mips64-elf and mips64-linux-gnu.  Applied.
Will be tested once gcc.target/mips uses gcc-dg.

Richard


gcc/
	* config/mips/mips.c (mips_rtx_costs): Add costs for CINS.

Patch

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2012-08-26 11:32:09.000000000 +0100
+++ gcc/config/mips/mips.c	2012-08-26 11:34:07.346812457 +0100
@@ -3681,6 +3681,18 @@  mips_rtx_costs (rtx x, int code, int out
 		    + set_src_cost (XEXP (x, 0), speed));
 	  return true;
 	}
+      if (ISA_HAS_CINS && CONST_INT_P (XEXP (x, 1)))
+	{
+	  rtx op = XEXP (x, 0);
+	  if (GET_CODE (op) == ASHIFT
+	      && CONST_INT_P (XEXP (op, 1))
+	      && mask_low_and_shift_p (mode, XEXP (x, 1), XEXP (op, 1), 32))
+	    {
+	      *total = COSTS_N_INSNS (1) + set_src_cost (XEXP (op, 0), speed);
+	      return true;
+	    }
+	}
+	    
       /* Fall through.  */
 
     case IOR: