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

Uros Bizjak ubizjak@gmail.com
Fri Nov 3 14:15:00 GMT 2006


Hello!

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

currently we generate:

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:

2006-11-03  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.md (*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.

Uros.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386-fpconst.diff
Type: application/octet-stream
Size: 769 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061103/8f15ad33/attachment.obj>


More information about the Gcc-patches mailing list