Patchwork [ARM] Clean up movw support

login
register
mail settings
Submitter Andrew Stubbs
Date April 20, 2011, 2:20 p.m.
Message ID <4DAEEBA5.70707@codesourcery.com>
Download mbox | patch
Permalink /patch/92213/
State New
Headers show

Comments

Andrew Stubbs - April 20, 2011, 2:20 p.m.
This patch doesn't change the compiler behaviour; it merely moves the 
support for MOVW's 16-bit immediate constant to const_ok_for_op.

This patch is broken out of my previous (rejected) Thumb2-constants 
patch. I'll be posting v2 of that patch soon, and this clean up will be 
required then.

OK?

Andrew
Richard Earnshaw - April 20, 2011, 3:46 p.m.
On Wed, 2011-04-20 at 15:20 +0100, Andrew Stubbs wrote:
> This patch doesn't change the compiler behaviour; it merely moves the 
> support for MOVW's 16-bit immediate constant to const_ok_for_op.
> 
> This patch is broken out of my previous (rejected) Thumb2-constants 
> patch. I'll be posting v2 of that patch soon, and this clean up will be 
> required then.
> 
> OK?
> 
> Andrew

2011-04-20  Andrew Stubbs  <ams@codesourcery.com>

        gcc/
        * config/arm/arm.c (arm_gen_constant): Move mowv support ....
        (const_ok_for_op): ... to here.

it's movw (not mowv :)

Otherwise OK.

R.
Andrew Stubbs - April 20, 2011, 4:35 p.m.
On 20/04/11 16:46, Richard Earnshaw wrote:
> 2011-04-20  Andrew Stubbs<ams@codesourcery.com>
>
>          gcc/
>          * config/arm/arm.c (arm_gen_constant): Move mowv support ....
>          (const_ok_for_op): ... to here.
>
> it's movw (not mowv :)
>
> Otherwise OK.

Committed, thanks.

Andrew

Patch

2011-04-20  Andrew Stubbs  <ams@codesourcery.com>

	gcc/
	* config/arm/arm.c (arm_gen_constant): Move mowv support ....
	(const_ok_for_op): ... to here.

--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -2461,6 +2461,13 @@  const_ok_for_op (HOST_WIDE_INT i, enum rtx_code code)
 
   switch (code)
     {
+    case SET:
+      /* See if we can use movw.  */
+      if (arm_arch_thumb2 && (i & 0xffff0000) == 0)
+	return 1;
+      else
+	return 0;
+
     case PLUS:
     case COMPARE:
     case EQ:
@@ -2820,9 +2827,7 @@  arm_gen_constant (enum rtx_code code, enum machine_mode mode, rtx cond,
     }
 
   /* If we can do it in one insn get out quickly.  */
-  if (const_ok_for_arm (val)
-      || (can_negate_initial && const_ok_for_arm (-val))
-      || (can_invert && const_ok_for_arm (~val)))
+  if (const_ok_for_op (val, code))
     {
       if (generate)
 	emit_constant_insn (cond,
@@ -2875,15 +2880,6 @@  arm_gen_constant (enum rtx_code code, enum machine_mode mode, rtx cond,
   switch (code)
     {
     case SET:
-      /* See if we can use movw.  */
-      if (arm_arch_thumb2 && (remainder & 0xffff0000) == 0)
-	{
-	  if (generate)
-	    emit_constant_insn (cond, gen_rtx_SET (VOIDmode, target,
-						   GEN_INT (val)));
-	  return 1;
-	}
-
       /* See if we can do this by sign_extending a constant that is known
 	 to be negative.  This is a good, way of doing it, since the shift
 	 may well merge into a subsequent insn.  */