This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] set -mabi=altivec with -ftree-vectorize
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dje at watson dot ibm dot com
- Date: Tue, 31 Jul 2007 09:14:57 +0200
- Subject: [patch] set -mabi=altivec with -ftree-vectorize
Hello,
using -O2 -maltivec -ftree-vectorize on ppc-linux leads to
misscompilations, as -mabi=altivec is not enabled there.
It would be somewhat annoying and error-prone to require a normal
user to know this and add the extra option. As David Edelsohn
suggested, this patch makes us enable -mabi=altivec automatically
with -ftree-vectorize.
Bootstrapped & regtested on ppc-linux.
Zdenek
* config/rs6000/rs6000.c (rs6000_override_options): Enable
-mabi=altivec with -ftree-vectorize.
* gcc.dg/pr32582-1.c: New test.
Index: testsuite/gcc.dg/pr32582-1.c
===================================================================
*** testsuite/gcc.dg/pr32582-1.c (revision 0)
--- testsuite/gcc.dg/pr32582-1.c (revision 0)
***************
*** 0 ****
--- 1,32 ----
+ /* { dg-do run { target { powerpc*-*-* && powerpc_altivec_ok } } } */
+ /* { dg-options "-O2 -ftree-vectorize -maltivec" } */
+
+ #include <stdlib.h>
+ #include <string.h>
+
+ char a[64];
+
+ void set (void)
+ {
+ int i;
+
+ for (i = 0; i < 64; i++)
+ a[i] = 'x';
+ }
+
+ void check (void)
+ {
+ int i;
+
+ for (i = 0; i < 64; i++)
+ if (a[i] != 0)
+ abort ();
+ }
+
+ int main (void)
+ {
+ set ();
+ memset (a, 0, sizeof a);
+ check ();
+ return 0;
+ }
Index: config/rs6000/rs6000.c
===================================================================
*** config/rs6000/rs6000.c (revision 127065)
--- config/rs6000/rs6000.c (working copy)
*************** rs6000_override_options (const char *def
*** 1537,1544 ****
rs6000_ieeequad = 1;
#endif
! /* Set Altivec ABI as default for powerpc64 linux. */
! if (TARGET_ELF && TARGET_64BIT)
{
rs6000_altivec_abi = 1;
TARGET_ALTIVEC_VRSAVE = 1;
--- 1537,1547 ----
rs6000_ieeequad = 1;
#endif
! /* Set Altivec ABI as default for powerpc64 linux. Also, if
! autovectorization is run, enable Altivec ABI in order to
! prevent misscompilations. */
! if ((TARGET_ELF && TARGET_64BIT)
! || (TARGET_ALTIVEC && flag_tree_vectorize))
{
rs6000_altivec_abi = 1;
TARGET_ALTIVEC_VRSAVE = 1;