Loading... (original) (raw)

On Linux, the C2 code generator can replace the value -0.0f with +0.0f (and also the value -0.0d with +0.0d). The reason is that in some *.ad files both the value -0.0f and +0.0f is treated as being 0.0 and can therefore be replaced with an immediate +0.0f embedded into an instruction.

For example, in the sparc.ad file, the 'fpclass' function is used to decide if a float node's content is +0.0:

predicate((n->getf() == 0) && (fpclass(n->getf()) == FP_PZERO));

On Solaris, 'fpclass' returns FP_PZERO if the parameter is +0.0f and FP_NZERO if the parameter is -0.0f. On Linux, however, 'fpclass' is not available and therefore 'fpclassify' is used.

'fpclassify' does not distinguish between ±0.0f, it returns FP_ZERO for both +0.0f and -0.0f.