[RFC & patch]: Fix PR27277

Uros Bizjak ubizjak@gmail.com
Tue May 2 17:42:00 GMT 2006


Hello!

Standard i387 constant load instructions (fldz, fld1, ...) are not 
generated anymore with latest gcc, even for simple testcases like:

double test(void)
{
    return 1.0;
}

The problem can be tracked to the interference between 
compress_load_constant () function in expr.c and legitimate_constant_p 
() function in the i386 backend. As legitimate_constant_p () declares 
all constants (including all FP constant) valid, it does not 
discriminate between "true" i387 constants, such as 0.0 and 1.0. 
According to this, compress_load_constant () function allways calculates 
the cost of loading the constant directly (oldcost) as the RTX cost of a 
simple SET pattern.
The cost of the float_extend pattern (newcost) is calculated as a SET 
from a FLOAT_EXTEND pattern, which is in DFmode case  equals to 0. As 
the cost is further calculated from the sub-pattern, it is exactly the 
same, as in previous case, so oldcost == newcost.

The proposed patch changes the condition to generate a FLOAT_EXTEND 
pattern a bit. If oldcost == newcost, the FLOAT_EXTEND pattern is 
skipped, and original pattern is emitted. This solves all cases, where 
FLOAT_EXTEND  cost is defined as 0. The rationale for this change is in 
the fact, that non-extended loads are simpler to optimize, so we should 
emit FLOAT_EXTEND only in case when it _really_ improves something 
(according to rtx_costs).

Patch is bootstrapped on x86_64-pc-linux-gnu, regtesting is in progress 
(I do not expect any failures with this patch ;)

2006-05-02  Uros Bizjak  <uros@kss-loka.si>

    PR target/27277
    * expr.c (compress_float_constant): Do not emit move as an
    extension when oldcost == newcost.

Uros.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386_floatex.diff
Type: text/x-patch
Size: 768 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060502/8aea3334/attachment.bin>


More information about the Gcc-patches mailing list