diff mbox

__intN patch 1/5: convert-move optimization

Message ID 201408132210.s7DMAUI7016357@greed.delorie.com
State New
Headers show

Commit Message

DJ Delorie Aug. 13, 2014, 10:10 p.m. UTC
This patch is part of the __intN series, but is independent.  It
provides an additional optimization opportunity, since the MSP430 does
a lot of conversions between HImode and PSImode.

	* expr.c (convert_move): If the target has an explicit converter,
	use it.

Comments

Jeff Law Aug. 29, 2014, 8:30 p.m. UTC | #1
On 08/13/14 16:10, DJ Delorie wrote:
> This patch is part of the __intN series, but is independent.  It
> provides an additional optimization opportunity, since the MSP430 does
> a lot of conversions between HImode and PSImode.
>
> 	* expr.c (convert_move): If the target has an explicit converter,
> 	use it.
OK.

A bit surprised we need it since I recall conversions between HImode and 
PSImode being "reasonable" on the mn102 eons ago.  But we may have 
changed something since then which is causing us to bounce to SImode 
first these days.

jeff
DJ Delorie Aug. 29, 2014, 11:19 p.m. UTC | #2
> > 	* expr.c (convert_move): If the target has an explicit converter,
> > 	use it.
> OK.

Thanks!  Committed.
diff mbox

Patch

Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 213886)
+++ gcc/expr.c	(working copy)
@@ -406,12 +406,32 @@  convert_move (rtx to, rtx from, int unsi
 								       from)
 			  : gen_rtx_FLOAT_EXTEND (to_mode, from));
       return;
     }
 
   /* Handle pointer conversion.  */			/* SPEE 900220.  */
+  /* If the target has a converter from FROM_MODE to TO_MODE, use it.  */
+  {
+    convert_optab ctab;
+
+    if (GET_MODE_PRECISION (from_mode) > GET_MODE_PRECISION (to_mode))
+      ctab = trunc_optab;
+    else if (unsignedp)
+      ctab = zext_optab;
+    else
+      ctab = sext_optab;
+
+    if (convert_optab_handler (ctab, to_mode, from_mode)
+	!= CODE_FOR_nothing)
+      {
+	emit_unop_insn (convert_optab_handler (ctab, to_mode, from_mode),
+			to, from, UNKNOWN);
+	return;
+      }
+  }
+
   /* Targets are expected to provide conversion insns between PxImode and
      xImode for all MODE_PARTIAL_INT modes they use, but no others.  */
   if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT)
     {
       enum machine_mode full_mode
 	= smallest_mode_for_size (GET_MODE_BITSIZE (to_mode), MODE_INT);