Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 209348)
+++ config/i386/i386.c	(working copy)
@@ -6806,8 +6806,9 @@ classify_argument (enum machine_mode mode, const_t
 }
 
 /* Examine the argument and return set number of register required in each
-   class.  Return 0 iff parameter should be passed in memory.  */
-static int
+   class.  Return true iff parameter should be passed in memory.  */
+
+static bool
 examine_argument (enum machine_mode mode, const_tree type, int in_return,
 		  int *int_nregs, int *sse_nregs)
 {
@@ -6816,8 +6817,9 @@ examine_argument (enum machine_mode mode, const_tr
 
   *int_nregs = 0;
   *sse_nregs = 0;
+
   if (!n)
-    return 0;
+    return true;
   for (n--; n >= 0; n--)
     switch (regclass[n])
       {
@@ -6835,15 +6837,15 @@ examine_argument (enum machine_mode mode, const_tr
 	break;
       case X86_64_X87_CLASS:
       case X86_64_X87UP_CLASS:
+      case X86_64_COMPLEX_X87_CLASS:
 	if (!in_return)
-	  return 0;
+	  return true;
 	break;
-      case X86_64_COMPLEX_X87_CLASS:
-	return in_return ? 2 : 0;
       case X86_64_MEMORY_CLASS:
 	gcc_unreachable ();
       }
-  return 1;
+
+  return false;
 }
 
 /* Construct container for the argument used by GCC interface.  See
@@ -6873,8 +6875,8 @@ construct_container (enum machine_mode mode, enum
   n = classify_argument (mode, type, regclass, 0);
   if (!n)
     return NULL;
-  if (!examine_argument (mode, type, in_return, &needed_intregs,
-			 &needed_sseregs))
+  if (examine_argument (mode, type, in_return, &needed_intregs,
+			&needed_sseregs))
     return NULL;
   if (needed_intregs > nintregs || needed_sseregs > nsseregs)
     return NULL;
@@ -7193,7 +7195,7 @@ function_arg_advance_64 (CUMULATIVE_ARGS *cum, enu
 		 || VALID_AVX256_REG_MODE (mode)))
     return;
 
-  if (examine_argument (mode, type, 0, &int_nregs, &sse_nregs)
+  if (!examine_argument (mode, type, 0, &int_nregs, &sse_nregs)
       && sse_nregs <= cum->sse_nregs && int_nregs <= cum->nregs)
     {
       cum->nregs -= int_nregs;
@@ -7988,95 +7990,87 @@ ix86_libcall_value (enum machine_mode mode)
 
 /* Return true iff type is returned in memory.  */
 
-static bool ATTRIBUTE_UNUSED
-return_in_memory_32 (const_tree type, enum machine_mode mode)
+static bool
+ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
 {
+#ifdef SUBTARGET_RETURN_IN_MEMORY
+  return SUBTARGET_RETURN_IN_MEMORY (type, fntype);
+#else
+  const enum machine_mode mode = type_natural_mode (type, NULL, true);
   HOST_WIDE_INT size;
 
-  if (mode == BLKmode)
-    return true;
+  if (TARGET_64BIT)
+    {
+      if (ix86_function_type_abi (fntype) == MS_ABI)
+	{
+	  size = int_size_in_bytes (type);
 
-  size = int_size_in_bytes (type);
+	  /* __m128 is returned in xmm0.  */
+	  if ((!type || VECTOR_INTEGER_TYPE_P (type)
+	       || INTEGRAL_TYPE_P (type)
+	       || VECTOR_FLOAT_TYPE_P (type))
+	      && (SCALAR_INT_MODE_P (mode) || VECTOR_MODE_P (mode))
+	      && !COMPLEX_MODE_P (mode)
+	      && (GET_MODE_SIZE (mode) == 16 || size == 16))
+	    return false;
 
-  if (MS_AGGREGATE_RETURN && AGGREGATE_TYPE_P (type) && size <= 8)
-    return false;
+	  /* Otherwise, the size must be exactly in [1248]. */
+	  return size != 1 && size != 2 && size != 4 && size != 8;
+	}
+      else
+	{
+	  int needed_intregs, needed_sseregs;
 
-  if (VECTOR_MODE_P (mode) || mode == TImode)
+	  return examine_argument (mode, type, 1,
+				   &needed_intregs, &needed_sseregs);
+	}
+    }
+  else
     {
-      /* User-created vectors small enough to fit in EAX.  */
-      if (size < 8)
-	return false;
+      if (mode == BLKmode)
+	return true;
 
-      /* MMX/3dNow values are returned in MM0,
-	 except when it doesn't exits or the ABI prescribes otherwise.  */
-      if (size == 8)
-	return !TARGET_MMX || TARGET_VECT8_RETURNS;
+      size = int_size_in_bytes (type);
 
-      /* SSE values are returned in XMM0, except when it doesn't exist.  */
-      if (size == 16)
-	return !TARGET_SSE;
+      if (MS_AGGREGATE_RETURN && AGGREGATE_TYPE_P (type) && size <= 8)
+	return false;
 
-      /* AVX values are returned in YMM0, except when it doesn't exist.  */
-      if (size == 32)
-	return !TARGET_AVX;
+      if (VECTOR_MODE_P (mode) || mode == TImode)
+	{
+	  /* User-created vectors small enough to fit in EAX.  */
+	  if (size < 8)
+	    return false;
 
-      /* AVX512F values are returned in ZMM0, except when it doesn't exist.  */
-      if (size == 64)
-	return !TARGET_AVX512F;
-    }
+	  /* Unless ABI prescibes otherwise,
+	     MMX/3dNow values are returned in MM0 if available.  */
+	     
+	  if (size == 8)
+	    return TARGET_VECT8_RETURNS || !TARGET_MMX;
 
-  if (mode == XFmode)
-    return false;
+	  /* SSE values are returned in XMM0 if available.  */
+	  if (size == 16)
+	    return !TARGET_SSE;
 
-  if (size > 12)
-    return true;
+	  /* AVX values are returned in YMM0 if available.  */
+	  if (size == 32)
+	    return !TARGET_AVX;
 
-  /* OImode shouldn't be used directly.  */
-  gcc_assert (mode != OImode);
+	  /* AVX512F values are returned in ZMM0 if available.  */
+	  if (size == 64)
+	    return !TARGET_AVX512F;
+	}
 
-  return false;
-}
+      if (mode == XFmode)
+	return false;
 
-static bool ATTRIBUTE_UNUSED
-return_in_memory_64 (const_tree type, enum machine_mode mode)
-{
-  int needed_intregs, needed_sseregs;
-  return !examine_argument (mode, type, 1, &needed_intregs, &needed_sseregs);
-}
+      if (size > 12)
+	return true;
 
-static bool ATTRIBUTE_UNUSED
-return_in_memory_ms_64 (const_tree type, enum machine_mode mode)
-{
-  HOST_WIDE_INT size = int_size_in_bytes (type);
+      /* OImode shouldn't be used directly.  */
+      gcc_assert (mode != OImode);
 
-  /* __m128 is returned in xmm0.  */
-  if ((!type || VECTOR_INTEGER_TYPE_P (type) || INTEGRAL_TYPE_P (type)
-       || VECTOR_FLOAT_TYPE_P (type))
-      && (SCALAR_INT_MODE_P (mode) || VECTOR_MODE_P (mode))
-      && !COMPLEX_MODE_P (mode) && (GET_MODE_SIZE (mode) == 16 || size == 16))
-    return false;
-
-  /* Otherwise, the size must be exactly in [1248]. */
-  return size != 1 && size != 2 && size != 4 && size != 8;
-}
-
-static bool
-ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
-{
-#ifdef SUBTARGET_RETURN_IN_MEMORY
-  return SUBTARGET_RETURN_IN_MEMORY (type, fntype);
-#else
-  const enum machine_mode mode = type_natural_mode (type, NULL, true);
-
-  if (TARGET_64BIT)
-    {
-      if (ix86_function_type_abi (fntype) == MS_ABI)
-	return return_in_memory_ms_64 (type, mode);
-      else
-	return return_in_memory_64 (type, mode);
+      return false;
     }
-  else
-    return return_in_memory_32 (type, mode);
 #endif
 }
 
