diff mbox

[i386] : Some trivial const_wide_int/const_double related cleanups

Message ID CAFULd4atwLafyb6axBin7mfPcgK0MNJsuOu6pPQd8WXZp2Q4dQ@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak May 4, 2015, 7:49 p.m. UTC
Hello!

2015-05-04  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.c: Change GET_CODE (...) == CONST_DOUBLE check
    to CONST_DOUBLE_P predicate.
    (standard_sse_constant_p): Return 0 for !TARGET_SSE.
    (ix86_legitimate_constant_p) <case CONST_WIDE_INT>: For 32bit targets,
    allow only operands that satisfy standard_sse_constant_p predicate.
    * config/i386/i386.md: Change GET_CODE (...) == CONST_DOUBLE check
    to CONST_DOUBLE_P predicate.

Tested on x86_64-linux-gnu {,-m32} and committed to mainline SVN.

Uros.
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 222767)
+++ config/i386/i386.c	(working copy)
@@ -9368,7 +9368,7 @@  standard_80387_constant_p (rtx x)
 
   REAL_VALUE_TYPE r;
 
-  if (!(X87_FLOAT_MODE_P (mode) && (GET_CODE (x) == CONST_DOUBLE)))
+  if (!(CONST_DOUBLE_P (x) && X87_FLOAT_MODE_P (mode)))
     return -1;
 
   if (x == CONST0_RTX (mode))
@@ -9469,9 +9469,14 @@  standard_80387_constant_rtx (int idx)
 int
 standard_sse_constant_p (rtx x)
 {
-  machine_mode mode = GET_MODE (x);
+  machine_mode mode;
 
-  if (x == const0_rtx || x == CONST0_RTX (GET_MODE (x)))
+  if (!TARGET_SSE)
+    return 0;
+
+  mode = GET_MODE (x);
+  
+  if (x == const0_rtx || x == CONST0_RTX (mode))
     return 1;
   if (vector_all_ones_operand (x, mode))
     switch (mode)
@@ -13078,9 +13083,7 @@  ix86_legitimate_constant_p (machine_mode, rtx x)
       break;
 
     case CONST_WIDE_INT:
-      if (GET_MODE (x) == TImode
-	  && x != CONST0_RTX (TImode)
-          && !TARGET_64BIT)
+      if (!TARGET_64BIT && !standard_sse_constant_p (x))
 	return false;
       break;
 
@@ -15903,7 +15906,7 @@  ix86_print_operand (FILE *file, rtx x, int code)
 	output_address (x);
     }
 
-  else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == SFmode)
+  else if (CONST_DOUBLE_P (x) && GET_MODE (x) == SFmode)
     {
       REAL_VALUE_TYPE r;
       long l;
@@ -15921,7 +15924,7 @@  ix86_print_operand (FILE *file, rtx x, int code)
 	fprintf (file, "0x%08x", (unsigned int) l);
     }
 
-  else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == DFmode)
+  else if (CONST_DOUBLE_P (x) && GET_MODE (x) == DFmode)
     {
       REAL_VALUE_TYPE r;
       long l[2];
@@ -15935,7 +15938,7 @@  ix86_print_operand (FILE *file, rtx x, int code)
     }
 
   /* These float cases don't actually occur as immediate operands.  */
-  else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) == XFmode)
+  else if (CONST_DOUBLE_P (x) && GET_MODE (x) == XFmode)
     {
       char dstr[30];
 
@@ -17364,8 +17367,7 @@  ix86_expand_move (machine_mode mode, rtx operands[
 	op1 = copy_to_mode_reg (mode, op1);
 
       if (can_create_pseudo_p ()
-	  && FLOAT_MODE_P (mode)
-	  && GET_CODE (op1) == CONST_DOUBLE)
+	  && CONST_DOUBLE_P (op1))
 	{
 	  /* If we are loading a floating point constant to a register,
 	     force the value to memory now, since we'll get better code
@@ -19563,7 +19565,7 @@  ix86_expand_copysign (rtx operands[])
   else
     vmode = mode;
 
-  if (GET_CODE (op0) == CONST_DOUBLE)
+  if (CONST_DOUBLE_P (op0))
     {
       rtx (*copysign_insn)(rtx, rtx, rtx, rtx);
 
@@ -22632,7 +22634,7 @@  ix86_split_to_parts (rtx operand, rtx *parts, mach
 	      for (i = 1; i < size; i++)
 		parts[i] = adjust_address (operand, SImode, 4 * i);
 	    }
-	  else if (GET_CODE (operand) == CONST_DOUBLE)
+	  else if (CONST_DOUBLE_P (operand))
 	    {
 	      REAL_VALUE_TYPE r;
 	      long l[4];
@@ -22683,7 +22685,7 @@  ix86_split_to_parts (rtx operand, rtx *parts, mach
 	      parts[0] = operand;
 	      parts[1] = adjust_address (operand, upper_mode, 8);
 	    }
-	  else if (GET_CODE (operand) == CONST_DOUBLE)
+	  else if (CONST_DOUBLE_P (operand))
 	    {
 	      REAL_VALUE_TYPE r;
 	      long l[4];
@@ -41208,7 +41210,7 @@  ix86_preferred_reload_class (rtx x, reg_class_t re
     return SSE_CLASS_P (regclass) ? regclass : NO_REGS;
 
   /* Floating-point constants need more complex checks.  */
-  if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) != VOIDmode)
+  if (CONST_DOUBLE_P (x))
     {
       /* General regs can load everything.  */
       if (reg_class_subset_p (regclass, GENERAL_REGS))
@@ -44551,9 +44553,9 @@  ix86_expand_vector_init (bool mmx_ok, rtx target,
   for (i = 0; i < n_elts; ++i)
     {
       x = XVECEXP (vals, 0, i);
-      if (!(CONST_INT_P (x)
-	    || GET_CODE (x) == CONST_DOUBLE
-	    || GET_CODE (x) == CONST_FIXED))
+      if (!(CONST_SCALAR_INT_P (x)
+	    || CONST_DOUBLE_P (x)
+	    || CONST_FIXED_P (x)))
 	n_var++, one_var = i;
       else if (x != CONST0_RTX (inner_mode))
 	all_const_zero = false;
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 222767)
+++ config/i386/i386.md	(working copy)
@@ -2955,7 +2955,7 @@ 
    && !(MEM_P (operands[0]) && MEM_P (operands[1]))
    && (!can_create_pseudo_p ()
        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
-       || GET_CODE (operands[1]) != CONST_DOUBLE
+       || !CONST_DOUBLE_P (operands[1])
        || (optimize_function_for_size_p (cfun)
 	   && standard_sse_constant_p (operands[1])
 	   && !memory_operand (operands[0], TFmode))
@@ -3025,7 +3025,7 @@ 
   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
    && (!can_create_pseudo_p ()
        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
-       || GET_CODE (operands[1]) != CONST_DOUBLE
+       || !CONST_DOUBLE_P (operands[1])
        || (optimize_function_for_size_p (cfun)
 	   && standard_80387_constant_p (operands[1]) > 0
 	   && !memory_operand (operands[0], XFmode))
@@ -3079,7 +3079,7 @@ 
   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
    && (!can_create_pseudo_p ()
        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
-       || GET_CODE (operands[1]) != CONST_DOUBLE
+       || !CONST_DOUBLE_P (operands[1])
        || (optimize_function_for_size_p (cfun)
 	   && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
 		&& standard_80387_constant_p (operands[1]) > 0)
@@ -3262,7 +3262,7 @@ 
   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
    && (!can_create_pseudo_p ()
        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
-       || GET_CODE (operands[1]) != CONST_DOUBLE
+       || !CONST_DOUBLE_P (operands[1])
        || (optimize_function_for_size_p (cfun)
 	   && ((!TARGET_SSE_MATH
 		&& standard_80387_constant_p (operands[1]) > 0)
@@ -3961,7 +3961,7 @@ 
 {
   /* ??? Needed for compress_float_constant since all fp constants
      are TARGET_LEGITIMATE_CONSTANT_P.  */
-  if (GET_CODE (operands[1]) == CONST_DOUBLE)
+  if (CONST_DOUBLE_P (operands[1]))
     {
       if ((!TARGET_SSE2 || TARGET_MIX_SSE_I387)
 	  && standard_80387_constant_p (operands[1]) > 0)
@@ -4077,7 +4077,7 @@ 
 {
   /* ??? Needed for compress_float_constant since all fp constants
      are TARGET_LEGITIMATE_CONSTANT_P.  */
-  if (GET_CODE (operands[1]) == CONST_DOUBLE)
+  if (CONST_DOUBLE_P (operands[1]))
     {
       if (standard_80387_constant_p (operands[1]) > 0)
 	{