This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch implements i387 register passing ABI extension for FP function arguments: a) unconditionally passes XFmode arguments of local functions in i387 registers b) passes DFmode and SFmode arguments of local functions in i387 registers for -ffast-math
c) for -m387regparm, passes XFmode arguments in i387 registers d) for -m387regparm, passes DFmode and SFmode arguments in 387 registers if -ffast-math is selected
--cut here-- static double __attribute__((noinline)) test(double a, double b) { return a / b; }
double foo(double a, double b) { return test(a, b); } --cut here--
gcc -O2 -fomit-frame-pointer -ffast-math: (loads FP arguments passed through memory to global function "foo" into x87 and passes them to local func "test"): test: fdivp %st, %st(1) ret
foo: fldl 4(%esp) fldl 12(%esp) fxch %st(1) jmp test
gcc -O2 -fomit-frame-pointer -ffast-math -m387regparm: test: fdivp %st, %st(1) ret foo: jmp test
gcc -O2 -fomit-frame-pointer -ffast-math -mfpmath=sse -msse2: test: divsd %xmm1, %xmm0 ret foo: subl $12, %esp movsd 24(%esp), %xmm1 movsd 16(%esp), %xmm0 call test movsd %xmm0, (%esp) fldl (%esp) addl $12, %esp ret
gcc -O2 -fomit-frame-pointer -ffast-math -mfpmath=sse -msse2 -m387regparm: test: divsd %xmm1, %xmm0 ret foo: subl $12, %esp fstpl (%esp) movsd (%esp), %xmm1 fstpl (%esp) movsd (%esp), %xmm0 call test movsd %xmm0, (%esp) fldl (%esp) addl $12, %esp ret
The patch was bootstrapped on i386-pc-linux-gnu and regression tested on c,c++ and fortran. Povray-3.6.1 was also compiled and its test run produced correct results. FWIW, the patch removed 96 "fld" instructions and 385 "fst" instructions from calls to local functions without any ABI violation.
Actually, this patch is fully functional, the only FIXME deals with error detection and subsequent edge stack correction if "dead" register is to be used (I never hit this problem). What remains as a WIP is just a couple of lines of documentation and a bunch of testcases.
YMMV, but this patch is expected to bring ~1% speedup on 32bit x87 FP intensive code.
* config/i386/i386.h (struct ix86_args): Add x87_nregs, x87_regno, float_in_x87: Add new variables. mmx_words, sse_words: Remove. (X87_REGPARM_MAX): Define.
* config/i386/i386.c (override_options): Error out for -m387regparm but no 80387 support. (ix86_attribute_table): Add 387regparm. (ix86_handle_cconv_attribute): Update comments for 387regparm. (ix86_comp_type_attributes): Check for mismatched 387regparm types. (ix86_function_387regparm): New function. (ix86_function_arg_regno_p): Add X87_REGPARM_MAX 80387 floating point registers. (init_cumulative_args): Initialize x87_nregs and float_in_x87 variables. (function_arg_advance): Process x87_nregs and x87_regno when floating point argument is to be passed in 80387 register. (function_arg): Pass SFmode and DFmode arguments in 80387 registers when cum->float_in_x87 and flag_unsafe_math_optimizations are set. Pass XFmode arguments in 80387 registers when cum->float_in_x87 is set.
* reg-stack.c (convert_regs_entry): =FIXME= Disable NaN load when function argument is passed through 80387 register.
Attachment:
i386-387regparm.c
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |