This is the mail archive of the 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]

[PATCH, i386]: Simplify float extension of XFmode constants


There is a small optimization opportunity exposed by fmod x87 builtin

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--

currently we generate:

       pushl   %ebp
       movl    %esp, %ebp
       fldl    8(%ebp)
       fldl    .LC0
       fxch    %st(1)

and patched gcc generates:
       pushl   %ebp
       movl    %esp, %ebp
       fldl    8(%ebp)
       fxch    %st(1)

2006-11-03 Uros Bizjak <>

	* config/i386/ (*movxf_nointeger, *movxf_integer): Enable
	patterns for standard 80387 constants.

Patch was bootstrapped and regtested on i686-pc-linux-gnu.

OK for mainline?

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]