User account creation filtered due to spam.

Bug 14960 - [3.4 only] -maltivec affects vector return with -mabi=no-altivec
Summary: [3.4 only] -maltivec affects vector return with -mabi=no-altivec
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-14 23:13 UTC by janis187
Modified: 2004-06-10 06:40 UTC (History)
4 users (show)

See Also:
Host:
Target: powerpc64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-04-14 23:25:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janis187 2004-04-14 23:13:42 UTC
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 Andrew 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 5 CVS Commits 2004-04-24 06:37:22 UTC
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

Comment 6 CVS Commits 2004-04-28 05:21:39 UTC
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

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 8 CVS Commits 2004-06-10 06:15:39 UTC
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

Comment 9 Alan Modra 2004-06-10 06:40:01 UTC
Fixed