[Bug target/14945] New: SSE/MMX args passed in regs to variadic functions

rridge at csclub dot uwaterloo dot ca gcc-bugzilla@gcc.gnu.org
Tue Apr 13 22:00:00 GMT 2004


When SSE/MMX vector types are passed to functions taking a variable
number of arguments, they're passed in registers instead of on
the stack where the called function expects them.

Test case:

#include <stdio.h>
#include <stdarg.h>

typedef double __attribute__((vector_size(16))) V4DF;

V4DF foo(int n, ...) {
	va_list ap;
	int i;
	static V4DF ret ;
	va_start(ap, n);
	for(i = 0; i < n; i++) {
		ret = va_arg(ap, V4DF);
	}
	va_end(ap);
	return ret;
}

int
main() {
	union {
		V4DF v;
		double d[2];
	} u;
	u.d[0] = 2.0;
	u.d[1] = 2.0;
	u.v = foo(1, u.v, 10.0, 10.0, 10.0, 10.0);
	printf("(%f,%f)\n", u.d[0], u.d[1]);
	return 0;	  
}

Compile with "gcc -msse2 t.c" and run.  Output is:

(10.000000,10.000000)

Expected output is:

(2.000000,2.000000)

The output of "gcc -v":

Reading specs from E:/UTIL/GCCHEAD/MINGW/BIN/../lib/gcc/mingw32/3.5.0/specs
Configured with: ../gcc/configure --prefix=e:/util/gcchead/mingw --target=mingw3
2 --host=mingw32 --enable-languages=c,c++
Thread model: single
gcc version 3.5.0 20040406 (experimental)

The problem seems to be in file "i386.c", function "init_cumulative_args":

    if (cum->nregs || !TARGET_MMX || !TARGET_SSE)

should be:

    if (cum->nregs || TARGET_MMX || TARGET_SSE)

-- 
           Summary: SSE/MMX args passed in regs to variadic functions
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rridge at csclub dot uwaterloo dot ca
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-mingw32
  GCC host triplet: i386-pc-mingw32
GCC target triplet: i386-pc-mingw32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14945



More information about the Gcc-bugs mailing list