The -maltivec instruction should enable the use of the AltiVec instruction set without affecting how function values are returned. The documentation in invoke.texi says for -maltivec, "you may also need to set -mabi=altivec to adjust the current ABI with Altivec ABI enhancements", but that doesn't appear to be required; two modules that are both compiled with either -mabi=altivec or -mabi=no-altivec should be intercallable, even if they pass vector arguments or have vector return values. Vector function return values are passed differently, though, depending on whether -maltivec is specified instead of which ABI is specified. This test case fails when either of the two files is compiled with -maltivec and the other is compiled without it, and both are compiled with -mabi=no-altivec. This is for either -m32 or -m64 for powerpc64-linux, with current GCC 3.4 branch. I'll try other branches soon and report what I find. --- bug.c -------------------------------------------------------------- /* Call a function whose return value is a vector. Define the data that the function will use as input, and verify that it returned the correct values. */ extern __attribute__((vector_size(16))) int foo (void); __attribute__((vector_size(16))) int i = { 100, 200, 300, 400 }; __attribute__((vector_size(16))) int j = { 10, 20, 30, 40 }; __attribute__((vector_size(16))) int k; extern void abort (void); extern __attribute__((vector_size(16))) int foo (void); void check () { union { __attribute__((vector_size(16))) int v; int i[4]; } u; u.v = k; if (u.i[0] != 110 || u.i[1] != 220 || u.i[2] != 330 || u.i[3] != 440) abort (); } int main () { k = foo (); check (); return 0; } --- buga.c ------------------------------------------------------------- /* Return a vector. */ extern __attribute__((vector_size(16))) int i, j; __attribute__((vector_size(16))) int foo (void) { return i + j; } ------------------------------------------------------------------------
Confirmed.
Yes, this is a bug. Looks to me, that rs6000_function_arg has a wrong check. I think, we should check for TARGET_ALTIVEC_ABI instead of TARGET_ALTIVEC, when we decide how to pass return value. Index: rs6000.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v retrieving revision 1.397.2.35 diff -u -p -r1.397.2.35 rs6000.c --- rs6000.c 30 Mar 2004 09:01:22 -0000 1.397.2.35 +++ rs6000.c 19 Apr 2004 09:21:52 -0000 @@ -16200,7 +16200,7 @@ rs6000_function_value (valtype, func) && TARGET_HARD_FLOAT && SPLIT_COMPLEX_ARGS) return rs6000_complex_function_value (mode); - else if (TREE_CODE (valtype) == VECTOR_TYPE && TARGET_ALTIVEC) + else if (TREE_CODE (valtype) == VECTOR_TYPE && TARGET_ALTIVEC_ABI) regno = ALTIVEC_ARG_RETURN; else regno = GP_ARG_RETURN;
Subject: Re: -maltivec affects vector return with -mabi=no-altivec > Yes, this is a bug. Looks to me, that rs6000_function_arg has a wrong check. > I think, we should check for TARGET_ALTIVEC_ABI instead of TARGET_ALTIVEC, > when we decide how to pass return value. Hartmut. This patch is OK. Please submit it to gcc-patches and commit it as preapproved by me. Then close the PR. Thank you. Aldy
Is this on hold because of other discussions about how altivec options are supposed to interact?
Subject: Bug 14960 CVSROOT: /cvs/gcc Module name: gcc Changes by: amodra@gcc.gnu.org 2004-04-24 06:37:20 Modified files: gcc : ChangeLog gcc/config/rs6000: rs6000.c rs6000.h Log message: PR target/14960 * config/rs6000/rs6000.c (rs6000_stack_info): Rename total_raw_size to non_fixed_size, and leave out fixed_size from the sum. (generate_set_vrsave): Correct clobbers. (rs6000_emit_epilogue): Test TARGET_ALTIVEC with TARGET_ALTIVEC_SAVE. (rs6000_function_value): Test TARGET_ALTIVEC and TARGET_ALTIVEC_ABI. (rs6000_libcall_value): Likewise. * config/rs6000/rs6000.h (FUNCTION_VALUE_REGNO_P): Likewise. (FUNCTION_ARG_REGNO_P): Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3477&r2=2.3478 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.c.diff?cvsroot=gcc&r1=1.629&r2=1.630 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.h.diff?cvsroot=gcc&r1=1.319&r2=1.320
Subject: Bug 14960 CVSROOT: /cvs/gcc Module name: gcc Branch: hammer-3_3-branch Changes by: amodra@gcc.gnu.org 2004-04-28 05:21:36 Modified files: gcc : ChangeLog.hammer gcc/config/rs6000: rs6000.c rs6000.h Log message: PR target/14960 * config/rs6000/rs6000.c (rs6000_stack_info): Rename total_raw_size to non_fixed_size, and leave out fixed_size from the sum. (generate_set_vrsave): Correct clobbers. (rs6000_emit_epilogue): Test TARGET_ALTIVEC with TARGET_ALTIVEC_SAVE. (rs6000_function_value): Test TARGET_ALTIVEC and TARGET_ALTIVEC_ABI. (rs6000_libcall_value): Likewise. * config/rs6000/rs6000.h (FUNCTION_VALUE_REGNO_P): Likewise. (FUNCTION_ARG_REGNO_P): Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.hammer.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.1.2.392&r2=1.1.2.393 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.c.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.397.2.37&r2=1.397.2.38 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.h.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.234.2.24&r2=1.234.2.25
Would one of you please apply the patch to 3.4 and close the PR?
Subject: Bug 14960 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: amodra@gcc.gnu.org 2004-06-10 06:15:32 Modified files: gcc : ChangeLog gcc/config/rs6000: rs6000.c rs6000.h Log message: PR target/14960 2004-04-24 Alan Modra <amodra@bigpond.net.au> * config/rs6000/rs6000.c (rs6000_stack_info): Rename total_raw_size to non_fixed_size, and leave out fixed_size from the sum. (generate_set_vrsave): Correct clobbers. (rs6000_emit_epilogue): Test TARGET_ALTIVEC with TARGET_ALTIVEC_SAVE. (rs6000_function_value): Test TARGET_ALTIVEC and TARGET_ALTIVEC_ABI. (rs6000_libcall_value): Likewise. * config/rs6000/rs6000.h (FUNCTION_VALUE_REGNO_P): Likewise. (FUNCTION_ARG_REGNO_P): Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.486&r2=2.2326.2.487 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.576.2.21&r2=1.576.2.22 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.306.4.5&r2=1.306.4.6
Fixed