Patchwork [committed] TILE-Gx: speed up code to synthesize a constant

login
register
mail settings
Submitter Walter Lee
Date March 26, 2013, 6:53 a.m.
Message ID <201303260653.r2Q6rpZB016993@farm-0001.internal.tilera.com>
Download mbox | patch
Permalink /patch/231094/
State New
Headers show

Comments

Walter Lee - March 26, 2013, 6:53 a.m.
This patch inlines some tests while searching for the best way to
synthesize a constant, to avoid the need to generate an rtx.  This
became expensive for code that generates a lot of constants.
Backported to 4.7 and 4.8.

	* config/tilegx/tilegx.c (expand_set_cint64_one_inst): Inline
        tests for constraint J, K, N, P.

Patch

Index: gcc/config/tilegx/tilegx.c
===================================================================
--- gcc/config/tilegx/tilegx.c	(revision 197073)
+++ gcc/config/tilegx/tilegx.c	(working copy)
@@ -1429,14 +1429,16 @@  expand_set_cint64_one_inst (rtx dest_reg
     }
   else if (!three_wide_only)
     {
-      rtx imm_op = GEN_INT (val);
-
-      if (satisfies_constraint_J (imm_op)
-	  || satisfies_constraint_K (imm_op)
-	  || satisfies_constraint_N (imm_op)
-	  || satisfies_constraint_P (imm_op))
+      /* Test for the following constraints: J, K, N, P.  We avoid
+	 generating an rtx and using existing predicates because we
+	 can be testing and rejecting a lot of constants, and GEN_INT
+	 is O(N).  */
+      if ((val >= -32768 && val <= 65535)
+	  || ((val == (val & 0xFF) * 0x0101010101010101LL))
+	  || (val == ((trunc_int_for_mode (val, QImode) & 0xFFFF)
+		      * 0x0001000100010001LL)))
 	{
-	  emit_move_insn (dest_reg, imm_op);
+	  emit_move_insn (dest_reg, GEN_INT (val));
 	  return true;
 	}
     }