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]

RFA: fix for 17961 (ppc vectors)


Hi folks.

This bug was marked middle-end, but the problem was actually in the back-end.
The macro ROUND_TYPE_ALIGN was setting an alignment of 128-bits for
*any* vector when -maltivec was used, regardless of if the vector was
supported by the hardware and required 128-bit alignment.  For smaller
vectors this produced a scalar DI or HI (vector_size=8 and vector_size=2
respectively-- see testcase) with an alignment of 128-bits.  The middle end 
was getting seriously confused when moving things around.  In one case it was
trying to move between an 128-bit V4SI and a 128-bit aligned DI.

I tried to look at the actual bug, but rth suggested it was not worth
the trouble.

The reason why this PR couldn't be reproduced on Darwin was because darwin.h
defined ROUND_TYPE_ALIGN correctly.

This patch fixes the PR, and has been bootstrapped and tested on ppc-linux.

David I see other vector tests xfail altivec tests on AIX.  This is just
a compile test, which should work everywhere.  I tried it on a cross
build of powerpc-ibm-aix*, passing -maltivec to the testcase, and it worked.
This is why I'm not appending:

  /* { dg-xfail-if "" { "powerpc-ibm-aix*" } { "-maltivec" } { "" } } */

...as the other gcc.dg/ vector tests do.  If you'd like me to exclude
AIX, let me know.

OK for mainline and 4.0 branch?

	PR 17961
	* config/rs6000/sysv4.h (ROUND_TYPE_ALIGN): Do not
	indiscriminately align vectors to 128-bits.

	* config/rs6000/linux64.h (ROUND_TYPE_ALIGN): Same.

	* testsuite/gcc.dg/simd-3.c: New.

Index: config/rs6000/sysv4.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.163
diff -c -p -r1.163 sysv4.h
*** config/rs6000/sysv4.h	1 Jun 2005 00:30:22 -0000	1.163
--- config/rs6000/sysv4.h	9 Jun 2005 21:36:20 -0000
*************** do {									\
*** 340,346 ****
     usual way is COMPUTED and the alignment explicitly specified was
     SPECIFIED.  */
  #define ROUND_TYPE_ALIGN(TYPE, COMPUTED, SPECIFIED)			\
! 	((TARGET_ALTIVEC  && TREE_CODE (TYPE) == VECTOR_TYPE)		\
  	 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)			\
  	 : MAX (COMPUTED, SPECIFIED))
  
--- 340,347 ----
     usual way is COMPUTED and the alignment explicitly specified was
     SPECIFIED.  */
  #define ROUND_TYPE_ALIGN(TYPE, COMPUTED, SPECIFIED)			\
! 	((TARGET_ALTIVEC  && TREE_CODE (TYPE) == VECTOR_TYPE		\
! 	  && ALTIVEC_VECTOR_MODE (TYPE_MODE (TYPE)))			\
  	 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)			\
  	 : MAX (COMPUTED, SPECIFIED))
  
Index: config/rs6000/linux64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/linux64.h,v
retrieving revision 1.77
diff -c -p -r1.77 linux64.h
*** config/rs6000/linux64.h	6 May 2005 13:40:29 -0000	1.77
--- config/rs6000/linux64.h	9 Jun 2005 21:36:20 -0000
*************** extern int dot_symbols;
*** 228,234 ****
     the first field is an FP double, only if in power alignment mode.  */
  #undef  ROUND_TYPE_ALIGN
  #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)			\
!   ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE)		\
     ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)				\
     : (TARGET_64BIT							\
        && (TREE_CODE (STRUCT) == RECORD_TYPE				\
--- 228,235 ----
     the first field is an FP double, only if in power alignment mode.  */
  #undef  ROUND_TYPE_ALIGN
  #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)			\
!   ((TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE			\
!     && ALTIVEC_VECTOR_MODE (TYPE_MODE (STRUCT)))			\
     ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)				\
     : (TARGET_64BIT							\
        && (TREE_CODE (STRUCT) == RECORD_TYPE				\
Index: testsuite/gcc.dg/simd-3.c
===================================================================
RCS file: testsuite/gcc.dg/simd-3.c
diff -N testsuite/gcc.dg/simd-3.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/simd-3.c	9 Jun 2005 21:36:20 -0000
***************
*** 0 ****
--- 1,16 ----
+ /* { dg-do compile } */
+ /* { dg-options "-maltivec" { target powerpc-*-* } } */
+ 
+ __attribute__ ((vector_size (2))) signed char v1, v2, v3;
+ void
+ one (void)
+ {
+   v1 = v2 + v3;
+ }
+ 
+ __attribute__ ((vector_size (8))) signed char v4, v5, v6;
+ void
+ two (void)
+ {
+   v4 = v5 + v6;
+ }


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