diff mbox

[4/11] Use precisions for TRULY_NOOP_TRUNCATION

Message ID 4E0E047F.2090703@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt July 1, 2011, 5:31 p.m. UTC
Most users of TRULY_NOOP_TRUNCATION have machine modes they want to
examine, so hide these behind a new macro TRULY_NOOP_TRUNCATION_MODES_P.
This now uses GET_MODE_PRECISION instead of GET_MODE_BITSIZE.


Bernd
* machmode.h (TRULY_NOOP_TRUNCATION_MODES_P): New macro.
	* combine.c (make_extraction, gen_lowpart_or_truncate,
	apply_distributive_law, simplify_comparison,
	reg_truncated_to_mode, record_truncated_value): Use it.
	* cse.c (notreg_cost): Likewise.
	* expmed.c (store_bit_field_1, extract_bit_field_1): Likewise.
	* expr.c (convert_move, convert_modes): Likewise.
	* optabs.c (expand_binop, expand_unop): Likewise.
	* postreload.c (move2add_last_label): Likewise.
	* regmove.c (optimize_reg_copy_3): Likewise.
	* rtlhooks.c (gen_lowpart_general): Likewise.
	* simplify-rtx.c (simplify_unary_operation_1): Likewise.

Comments

Richard Henderson July 5, 2011, 7:11 p.m. UTC | #1
On 07/01/2011 10:31 AM, Bernd Schmidt wrote:
> 	* machmode.h (TRULY_NOOP_TRUNCATION_MODES_P): New macro.
> 	* combine.c (make_extraction, gen_lowpart_or_truncate,
> 	apply_distributive_law, simplify_comparison,
> 	reg_truncated_to_mode, record_truncated_value): Use it.
> 	* cse.c (notreg_cost): Likewise.
> 	* expmed.c (store_bit_field_1, extract_bit_field_1): Likewise.
> 	* expr.c (convert_move, convert_modes): Likewise.
> 	* optabs.c (expand_binop, expand_unop): Likewise.
> 	* postreload.c (move2add_last_label): Likewise.
> 	* regmove.c (optimize_reg_copy_3): Likewise.
> 	* rtlhooks.c (gen_lowpart_general): Likewise.
> 	* simplify-rtx.c (simplify_unary_operation_1): Likewise.

Ok.


r~
diff mbox

Patch

Index: baseline-trunk/gcc/combine.c
===================================================================
--- baseline-trunk.orig/gcc/combine.c
+++ baseline-trunk/gcc/combine.c
@@ -7141,8 +7141,7 @@  make_extraction (enum machine_mode mode,
 	   && !MEM_P (inner)
 	   && (inner_mode == tmode
 	       || !REG_P (inner)
-	       || TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (tmode),
-					 GET_MODE_BITSIZE (inner_mode))
+	       || TRULY_NOOP_TRUNCATION_MODES_P (tmode, inner_mode)
 	       || reg_truncated_to_mode (tmode, inner))
 	   && (! in_dest
 	       || (REG_P (inner)
@@ -7411,8 +7410,8 @@  make_extraction (enum machine_mode mode,
       /* On the LHS, don't create paradoxical subregs implicitely truncating
 	 the register unless TRULY_NOOP_TRUNCATION.  */
       if (in_dest
-	  && !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE (inner)),
-				     GET_MODE_BITSIZE (wanted_inner_mode)))
+	  && !TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (inner),
+					     wanted_inner_mode))
 	return NULL_RTX;
 
       if (GET_MODE (inner) != wanted_inner_mode
@@ -8048,8 +8047,7 @@  gen_lowpart_or_truncate (enum machine_mo
 {
   if (!CONST_INT_P (x)
       && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (x))
-      && !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-				 GET_MODE_BITSIZE (GET_MODE (x)))
+      && !TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (x))
       && !(REG_P (x) && reg_truncated_to_mode (mode, x)))
     {
       /* Bit-cast X into an integer mode.  */
@@ -9263,9 +9261,8 @@  apply_distributive_law (rtx x)
 	  || GET_MODE_SIZE (GET_MODE (SUBREG_REG (lhs))) > UNITS_PER_WORD
 	  /* Result might need to be truncated.  Don't change mode if
 	     explicit truncation is needed.  */
-	  || !TRULY_NOOP_TRUNCATION
-	       (GET_MODE_BITSIZE (GET_MODE (x)),
-		GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (lhs)))))
+	  || !TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (x),
+					     GET_MODE (SUBREG_REG (lhs))))
 	return x;
 
       tem = simplify_gen_binary (code, GET_MODE (SUBREG_REG (lhs)),
@@ -11694,8 +11691,7 @@  simplify_comparison (enum rtx_code code,
 				  + 1)) >= 0
 	      && const_op >> i == 0
 	      && (tmode = mode_for_size (i, MODE_INT, 1)) != BLKmode
-	      && (TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (tmode),
-					 GET_MODE_BITSIZE (GET_MODE (op0)))
+	      && (TRULY_NOOP_TRUNCATION_MODES_P (tmode, GET_MODE (op0))
 		  || (REG_P (XEXP (op0, 0))
 		      && reg_truncated_to_mode (tmode, XEXP (op0, 0)))))
 	    {
@@ -12508,8 +12504,7 @@  reg_truncated_to_mode (enum machine_mode
     return false;
   if (GET_MODE_SIZE (truncated) <= GET_MODE_SIZE (mode))
     return true;
-  if (TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-			     GET_MODE_BITSIZE (truncated)))
+  if (TRULY_NOOP_TRUNCATION_MODES_P (mode, truncated))
     return true;
   return false;
 }
@@ -12534,8 +12529,7 @@  record_truncated_value (rtx *p, void *da
       if (GET_MODE_SIZE (original_mode) <= GET_MODE_SIZE (truncated_mode))
 	return -1;
 
-      if (TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (truncated_mode),
-				 GET_MODE_BITSIZE (original_mode)))
+      if (TRULY_NOOP_TRUNCATION_MODES_P (truncated_mode, original_mode))
 	return -1;
 
       x = SUBREG_REG (x);
Index: baseline-trunk/gcc/cse.c
===================================================================
--- baseline-trunk.orig/gcc/cse.c
+++ baseline-trunk/gcc/cse.c
@@ -761,8 +761,8 @@  notreg_cost (rtx x, enum rtx_code outer)
 	   && (GET_MODE_SIZE (GET_MODE (x))
 	       < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
 	   && subreg_lowpart_p (x)
-	   && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE (x)),
-				     GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))))
+	   && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (x),
+					     GET_MODE (SUBREG_REG (x))))
 	  ? 0
 	  : rtx_cost (x, outer, optimize_this_for_speed_p) * 2);
 }
Index: baseline-trunk/gcc/dse.c
===================================================================
--- baseline-trunk.orig/gcc/dse.c
+++ baseline-trunk/gcc/dse.c
@@ -1722,8 +1722,7 @@  find_shift_sequence (int access_size,
       /* Try a wider mode if truncating the store mode to NEW_MODE
 	 requires a real instruction.  */
       if (GET_MODE_BITSIZE (new_mode) < GET_MODE_BITSIZE (store_mode)
-	  && !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (new_mode),
-				     GET_MODE_BITSIZE (store_mode)))
+	  && !TRULY_NOOP_TRUNCATION_MODES_P (new_mode, store_mode))
 	continue;
 
       /* Also try a wider mode if the necessary punning is either not
Index: baseline-trunk/gcc/expmed.c
===================================================================
--- baseline-trunk.orig/gcc/expmed.c
+++ baseline-trunk/gcc/expmed.c
@@ -635,9 +635,8 @@  store_bit_field_1 (rtx str_rtx, unsigned
 	 X) 0)) is (reg:N X).  */
       if (GET_CODE (xop0) == SUBREG
 	  && REG_P (SUBREG_REG (xop0))
-	  && (!TRULY_NOOP_TRUNCATION
-	      (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (xop0))),
-	       GET_MODE_BITSIZE (op_mode))))
+	  && (!TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (SUBREG_REG (xop0)),
+					      op_mode)))
 	{
 	  rtx tem = gen_reg_rtx (op_mode);
 	  emit_move_insn (tem, xop0);
@@ -1304,8 +1303,7 @@  extract_bit_field_1 (rtx str_rtx, unsign
 	       ? bitpos + bitsize == BITS_PER_WORD
 	       : bitpos == 0)))
       && ((!MEM_P (op0)
-	   && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode1),
-				     GET_MODE_BITSIZE (GET_MODE (op0)))
+	   && TRULY_NOOP_TRUNCATION_MODES_P (mode1, GET_MODE (op0))
 	   && GET_MODE_SIZE (mode1) != 0
 	   && byte_offset % GET_MODE_SIZE (mode1) == 0)
 	  || (MEM_P (op0)
@@ -1475,8 +1473,7 @@  extract_bit_field_1 (rtx str_rtx, unsign
 	     mode.  Instead, create a temporary and use convert_move to set
 	     the target.  */
 	  if (REG_P (xtarget)
-	      && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE (xtarget)),
-					GET_MODE_BITSIZE (ext_mode)))
+	      && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (xtarget), ext_mode))
 	    {
 	      xtarget = gen_lowpart (ext_mode, xtarget);
 	      if (GET_MODE_SIZE (ext_mode)
Index: baseline-trunk/gcc/expr.c
===================================================================
--- baseline-trunk.orig/gcc/expr.c
+++ baseline-trunk/gcc/expr.c
@@ -586,8 +586,7 @@  convert_move (rtx to, rtx from, int unsi
 
   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
-      && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
-				GET_MODE_BITSIZE (from_mode)))
+      && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, from_mode))
     {
       if (!((MEM_P (from)
 	     && ! MEM_VOLATILE_P (from)
@@ -625,8 +624,7 @@  convert_move (rtx to, rtx from, int unsi
 	    if (((can_extend_p (to_mode, intermediate, unsignedp)
 		  != CODE_FOR_nothing)
 		 || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate)
-		     && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
-					       GET_MODE_BITSIZE (intermediate))))
+		     && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, intermediate)))
 		&& (can_extend_p (intermediate, from_mode, unsignedp)
 		    != CODE_FOR_nothing))
 	      {
@@ -754,8 +752,8 @@  convert_modes (enum machine_mode mode, e
 		      || (REG_P (x)
 			  && (! HARD_REGISTER_P (x)
 			      || HARD_REGNO_MODE_OK (REGNO (x), mode))
-			  && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-						    GET_MODE_BITSIZE (GET_MODE (x)))))))))
+			  && TRULY_NOOP_TRUNCATION_MODES_P (mode,
+							    GET_MODE (x))))))))
     {
       /* ?? If we don't know OLDMODE, we have to assume here that
 	 X does not need sign- or zero-extension.   This may not be
Index: baseline-trunk/gcc/machmode.h
===================================================================
--- baseline-trunk.orig/gcc/machmode.h
+++ baseline-trunk/gcc/machmode.h
@@ -275,4 +275,8 @@  extern enum machine_mode ptr_mode;
 /* Target-dependent machine mode initialization - in insn-modes.c.  */
 extern void init_adjust_machine_modes (void);
 
+#define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2) \
+  TRULY_NOOP_TRUNCATION (GET_MODE_PRECISION (MODE1), \
+			 GET_MODE_PRECISION (MODE2))
+
 #endif /* not HAVE_MACHINE_MODES */
Index: baseline-trunk/gcc/optabs.c
===================================================================
--- baseline-trunk.orig/gcc/optabs.c
+++ baseline-trunk/gcc/optabs.c
@@ -1440,8 +1440,7 @@  expand_binop (enum machine_mode mode, op
       if (temp != 0)
 	{
 	  if (GET_MODE_CLASS (mode) == MODE_INT
-	      && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-                                        GET_MODE_BITSIZE (GET_MODE (temp))))
+	      && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (temp)))
 	    return gen_lowpart (mode, temp);
 	  else
 	    return convert_to_mode (mode, temp, unsignedp);
@@ -1498,8 +1497,7 @@  expand_binop (enum machine_mode mode, op
 	    if (temp)
 	      {
 		if (mclass != MODE_INT
-                    || !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-                                               GET_MODE_BITSIZE (wider_mode)))
+                    || !TRULY_NOOP_TRUNCATION_MODES_P (mode, wider_mode))
 		  {
 		    if (target == 0)
 		      target = gen_reg_rtx (mode);
@@ -2027,8 +2025,7 @@  expand_binop (enum machine_mode mode, op
 	      if (temp)
 		{
 		  if (mclass != MODE_INT
-		      || !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-						 GET_MODE_BITSIZE (wider_mode)))
+		      || !TRULY_NOOP_TRUNCATION_MODES_P (mode, wider_mode))
 		    {
 		      if (target == 0)
 			target = gen_reg_rtx (mode);
@@ -2915,8 +2912,7 @@  expand_unop (enum machine_mode mode, opt
 	    if (temp)
 	      {
 		if (mclass != MODE_INT
-		    || !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-					       GET_MODE_BITSIZE (wider_mode)))
+		    || !TRULY_NOOP_TRUNCATION_MODES_P (mode, wider_mode))
 		  {
 		    if (target == 0)
 		      target = gen_reg_rtx (mode);
Index: baseline-trunk/gcc/postreload.c
===================================================================
--- baseline-trunk.orig/gcc/postreload.c
+++ baseline-trunk/gcc/postreload.c
@@ -1643,8 +1643,7 @@  static int move2add_last_label_luid;
 #define MODES_OK_FOR_MOVE2ADD(OUTMODE, INMODE) \
   (GET_MODE_SIZE (OUTMODE) == GET_MODE_SIZE (INMODE) \
    || (GET_MODE_SIZE (OUTMODE) <= GET_MODE_SIZE (INMODE) \
-       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (OUTMODE), \
-				 GET_MODE_BITSIZE (INMODE))))
+       && TRULY_NOOP_TRUNCATION_MODES_P (OUTMODE, INMODE)))
 
 /* This function is called with INSN that sets REG to (SYM + OFF),
    while REG is known to already have value (SYM + offset).
Index: baseline-trunk/gcc/regmove.c
===================================================================
--- baseline-trunk.orig/gcc/regmove.c
+++ baseline-trunk/gcc/regmove.c
@@ -548,8 +548,7 @@  optimize_reg_copy_3 (rtx insn, rtx dest,
   /* Do not use a SUBREG to truncate from one mode to another if truncation
      is not a nop.  */
   if (GET_MODE_BITSIZE (GET_MODE (src_reg)) <= GET_MODE_BITSIZE (GET_MODE (src))
-      && !TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE (src)),
-				 GET_MODE_BITSIZE (GET_MODE (src_reg))))
+      && !TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (src), GET_MODE (src_reg)))
     return;
 
   set_insn = p;
Index: baseline-trunk/gcc/rtlhooks.c
===================================================================
--- baseline-trunk.orig/gcc/rtlhooks.c
+++ baseline-trunk/gcc/rtlhooks.c
@@ -61,8 +61,7 @@  gen_lowpart_general (enum machine_mode m
       /* The following exposes the use of "x" to CSE.  */
       if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD
 	  && SCALAR_INT_MODE_P (GET_MODE (x))
-	  && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-				    GET_MODE_BITSIZE (GET_MODE (x)))
+	  && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (x))
 	  && !reload_completed)
 	return gen_lowpart_general (mode, force_reg (GET_MODE (x), x));
 
Index: baseline-trunk/gcc/simplify-rtx.c
===================================================================
--- baseline-trunk.orig/gcc/simplify-rtx.c
+++ baseline-trunk/gcc/simplify-rtx.c
@@ -852,8 +852,7 @@  simplify_unary_operation_1 (enum rtx_cod
          truncation.  But don't do this for an (LSHIFTRT (MULT ...))
          since this will cause problems with the umulXi3_highpart
          patterns.  */
-      if ((TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-				 GET_MODE_BITSIZE (GET_MODE (op)))
+      if ((TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (op))
 	   ? (num_sign_bit_copies (op, GET_MODE (op))
 	      > (unsigned int) (GET_MODE_BITSIZE (GET_MODE (op))
 				- GET_MODE_BITSIZE (mode)))