[PATCH, i386] Optionally use %xmm0 to return float and/or double values
Paolo Bonzini
paolo.bonzini@lu.unisi.ch
Tue Jan 25 15:23:00 GMT 2005
The attached patch implements the idea of returning floating point
values in SSE registers. This is done as long as the ISA supports it
(e.g. for floats on SSE processors, or for doubles on SSE2):
1) with the new -mfp-ret-in-sse option, for all functions
2) with -mfpmath=sse, for local functions
3) without any option, for functions that have the sse_return attribute.
Given the advanced state of development of 4.0.0, I have included a few
asserts. Also, the code will not trigger unless the specific
command-line options -mfpmath=sse or -mfp-ret-in-sse are included. It
does not apply to x86-64 platforms, for which -mfpmath=sse is the
default, because their ABI implementation is completely separate.
There are 9 new testcases:
- 2 compilation tests for -mfp-ret-in-sse (-msse, -msse2)
- 2 compilation tests for static functions (-msse, -msse2)
- 2 run-time tests for -mfp-ret-in-sse (-msse, -msse2)
- 3 compilation tests for sse_return (-msse, -msse2, no option) testing
also warnings for inappropriate use of sse_return.
Here are some examples, taken from the new testcases:
1) Options used: -msse -mfp-ret-in-sse -mfpmath=sse:
float x() { return 3.14159265; }
float y(float a) { return a * x(); }
x:
movss .LC0, %xmm0
ret
y:
call x
mulss 4(%esp), %xmm0
ret
2) -msse2 -mfp-ret-in-sse -mfpmath=sse:
double x() { return 3.14159265; }
double y(float a) { return a * x(); }
x:
movsd .LC0, %xmm0
ret
y:
call x
mulsd 4(%esp), %xmm0
ret
3) -msse2 -mfpmath=sse -O2 -fomit-frame-pointer -fno-inline
(and the standard -mfp-ret-in-i387)
static double x() { return 3.14159265; }
double y(double a) { return a * x(); }
x:
movsd .LC0, %xmm0
ret
y:
subl $12, %esp
fldl 16(%esp)
fstpl (%esp)
call x
mulsd (%esp), %xmm0
movsd %xmm0, (%esp)
fldl (%esp)
addl $12, %esp
ret
where the global function is still using the %st0-based calling
convention.
Booted i686-pc-linux-gnu (P4), all languages except Ada,
tests in progress (gcc directory already done).
Ok for mainline?
Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fp-ret-sse.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050125/9ea85f3e/attachment.ksh>
More information about the Gcc-patches
mailing list