[Patch, i386]: Commited: macroize fmod and remainder x87 patterns

Uros Bizjak ubizjak@gmail.com
Sat Nov 25 15:04:00 GMT 2006


This relatively boring patch macroizes fmod and remainder i387 patterns.

However, as fprem{,1}xf4_i387 patterns are inserted in a tight loop, 
implementation using float_extend patterns produce quite unoptimal code. 
To maintain optimal register live information, fprem pattern must be 
generated as:

gen_insn (gen_fpremxf4_i387 (op1, op2, op1, op2))

where op1 and op2 represent registers holding XFmode value, extended to 
XFmode before the loop.

When fpremxf4_i387 pattern is implemented as

(define_insn "fpremxf4_i387"
  [(set (match_operand:XF 0 "register_operand" "=f")
        (unspec:XF [(float_extend:XF (match_operand:DF 2 
"register_operand" "0"))
                    (float_extend:XF (match_operand:DF 3 
"register_operand" "1"))]

This pattern is generated from fmoddf3 expander as:

gen_insn(gen_fpremxf4_i387(op1, op2, operands[1], operands[2])

Unfortunatelly, in this case life analysis figures out that operands[2] 
operand dies inside the loop, and a couple of compensating fstp and flds 
are emitted inside the loop. So, current fpremxf4_i387 pattern (without 
inherent XFmode extension) produces better code (tighter fmod reduction 

Other than a straightforward DFmode and SFmode macroization, this patch 
relaxes operand constraints a bit. All input operands are moved through 
extend<mode>xf2 pattern, they can be constrainted ad "general_operands", 
to match extend<mode>xf2 input operands.

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

        config/i386/i386.md (fpremxf4): Rename to fpremxf4_i387.
        (fprem1xf4): Rename to fprem1xf4_i387.

        (fmodsf3, fmoddf3): Macroize patterns using X87MODEF12 mode macro.
        Rename patterns to fmod<mode>3. Use general_operand operand
        constraint for operands 1 and 2. Use SSE_FLOAT_MODE_P to disable
        patterns for SSE math.
        (remaindersf3, remainderdf3): Ditto.

Patch was regression tested on i686-pc-linux-gnu for c, c++ and fortran. 
At the end, it has distilled to quite trivial patch, so I guess it can 
be committed to SVN under obvious rule. (Patch also includes trivial 
rename of "sqrt<mode>xf2_i387" to "sqrt_extend<mode>xf2_i387", 
mistakenly left out of my previous patch.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386-fprem.diff
Type: text/x-patch
Size: 7045 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061125/3c7517e6/attachment.bin>

More information about the Gcc-patches mailing list