14960 – [3.4 only] -maltivec affects vector return with -mabi=no-altivec (original) (raw)
| 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; } ------------------------------------------------------------------------ Comment 1 Drea Pinski 2004-04-14 23:25:07 UTC Confirmed. Comment 2 Hartmut Penner 2004-04-19 09:25:32 UTC 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; Comment 3 Aldy Hernandez 2004-04-19 10:55:02 UTC 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 Comment 4 janis187 2004-04-22 21:53:57 UTC Is this on hold because of other discussions about how altivec options are supposed to interact? Comment 7 Mark Mitchell 2004-06-05 20:33:21 UTC Would one of you please apply the patch to 3.4 and close the PR? Comment 9 Alan Modra 2004-06-10 06:40:01 UTC Fixed | | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |