This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, ARM_VFP] Correctly handle vectors in base standard


The following was identified by Joseph Myers, I've applied it to the
hard-vfp branch:

This patch fixes a problem with the VFP ABI changes that I discovered 
through reading the code: they would cause vectors to be returned in 
memory for base AAPCS, whereas AAPCS says that 64-bit and 128-bit
vectors 
should be returned in registers (and GCC applied this also to any 
funny-size generic vectors up to 128 bits).  Tested using the compat
tests 
between new and old GCC (without the patch,

FAIL: gcc.dg/compat/vector-1 c_compat_x_tst.o-c_compat_y_alt.o execute 
FAIL: gcc.dg/compat/vector-1 c_compat_x_alt.o-c_compat_y_tst.o execute 
FAIL: gcc.dg/compat/vector-2 c_compat_x_tst.o-c_compat_y_alt.o execute 
FAIL: gcc.dg/compat/vector-2 c_compat_x_alt.o-c_compat_y_tst.o execute 

appeared, and with the patch they disappeared).


2009-03-05  Joseph Myers  <joseph@codesourcery.com>

        * config/arm/arm.c (arm_return_in_memory): Handle returning
        vectors of suitable size in registers also for AAPCS case.
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 144613)
+++ config/arm/arm.c	(working copy)
@@ -2901,6 +2901,8 @@ arm_return_in_memory (const_tree type, c
 {
   HOST_WIDE_INT size;
 
+  size = int_size_in_bytes (type);  /* Negative if not fixed size.  */
+
   if (TARGET_AAPCS_BASED)
     {
       /* Simple, non-aggregate types (ie not including vectors and
@@ -2914,7 +2916,6 @@ arm_return_in_memory (const_tree type, c
 
       /* Any return value that is no larger than one word can be
 	 returned in r0.  */
-      size = int_size_in_bytes (type);  /* Negative if not fixed size.  */
       if (((unsigned HOST_WIDE_INT) size) <= UNITS_PER_WORD)
 	return false;
 
@@ -2925,15 +2926,16 @@ arm_return_in_memory (const_tree type, c
       if (aapcs_select_return_coproc (type, fntype) >= 0)
 	return false;
 
+      /* Vector values should be returned using ARM registers, not
+	 memory (unless they're over 16 bytes, which will break since
+	 we only have four call-clobbered registers to play with).  */
+      if (TREE_CODE (type) == VECTOR_TYPE)
+	return (size < 0 || size > (4 * UNITS_PER_WORD));
+
       /* The rest go in memory.  */
       return true;
     }
-  
-  size = int_size_in_bytes (type);
 
-  /* Vector values should be returned using ARM registers, not memory (unless
-     they're over 16 bytes, which will break since we only have four
-     call-clobbered registers to play with).  */
   if (TREE_CODE (type) == VECTOR_TYPE)
     return (size < 0 || size > (4 * UNITS_PER_WORD));
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]