[PATCH 14851] Partial fix for suboptimal fp division with -ffast-math

Roger Sayle roger@eyesopen.com
Tue Sep 21 03:01:00 GMT 2004


On Mon, 20 Sep 2004, Uros Bizjak wrote:
> 2004-09-20  Uros Bizjak  <uros@kss-loka.si>
>
>     * rtlanal.c (commutative_operand_precedence): Calculate
>     precedence of stripped constant.
>     * simplify-rtx.c (simplify_binary_operation): Return
>     memory reference to constant pool if operands are constant
>     pool references.


The rtlanal.c change is OK for mainline.  For the force_const_mem
change, I'm not sure that simplify_binary_operation is the correct
place to fix this.  I think a better strategy would be to fix this
deep in try_combine, where if an attempt to recognize a simplified
expression fails, we check for CONST_DOUBLE operands, force them
to memory and then try to recognize the instruction again.  This
should catch all the CONST_DOUBLE_FROM_REAL_VALUE cases that you're
worried about, without adversely affecting further optimizations or
other platforms which may suffer by tweaking simplify-rtx directly.

Does this seem like a reasonable strategy?  Anyone else agree or
disagree?

The real fix to rtl-optimization is to move the a/b -> a * (1.0/b)
transformation to tree-ssa, and only apply it if we're sure that 1.0/b
is used more than once, rather than try to get the RTL optimizers to
clean up the mess when it isn't a win.  For example, this is much
cleaner done as a form of loop strength reduction with the LNO
infrastructure.

Roger
--



More information about the Gcc-patches mailing list