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] |
There is a small optimization opportunity exposed by fmod x87 builtin instruction.
The fmod{xf,df}3 expander extends its input operands into XFmode, before calling fpremxf4. The problem arises for standard x87 constants, as we generate float extend of a memory symbol:
#(insn:TI 13 49 14 (set (reg:XF 8 st) # (float_extend:XF (mem/c/i:DF (plus:SI (reg/f:SI 6 bp) # (const_int 8 [0x8])) [3 a+0 S8 A32]))) 88 {*extenddfxf2_i387} (nil) # (nil)) fldl 8(%ebp) # 13 *extenddfxf2_i387/1 [length = 3]
Unfortunatelly, this pattern can't be simplified during combine, as const_double operands become valid for movxf pattern only during reload. This functionality was introduced mainly for movdf and movsf patterns to generate more x87 instructions with memory operands.
However, there is no XFmode x87 arithmetic instruction having memory operand, so by enabling movxf for standard x87 constants, we actually loose nothing. OTOH, combine is now able to simplify XFmode float_extend pattern into simple constant load.
This is the testcase: --cut here-- double t (double a, double b) { return fmod (a, 1.0); } --cut here--
t: pushl %ebp movl %esp, %ebp fldl 8(%ebp) fldl .LC0 fxch %st(1) .L2:
and patched gcc generates: t: pushl %ebp movl %esp, %ebp fldl 8(%ebp) fld1 fxch %st(1) .L2:
* config/i386/i386.md (*movxf_nointeger, *movxf_integer): Enable patterns for standard 80387 constants.
BTW: For the record - I tried to enable movsf and movdf patterns for standard 80387 const_double constants in the same way, and this resulted in noticeably slower code.
Attachment:
i386-fpconst.diff
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |