Skip to main content

IAR Embedded Workbench for RH850 3.20.x

‑‑relaxed_fp

In this section:
Syntax

‑‑relaxed_fp

Description

Use this option to allow the compiler to relax the language rules and perform more aggressive optimization of floating-point expressions. This option improves performance for floating-point expressions that fulfill these conditions:

  • The expression consists of both single and double-precision values

  • The double-precision values can be converted to single precision without loss of accuracy

  • The result of the expression is converted to single precision.

Note

Performing the calculation in single precision instead of double precision might cause a loss of accuracy.

When the ‑‑relaxed_fp option is used, errno might not be set according to Standard C for negative arguments to the functionsqrt. Therefore, your source code should not rely on errno.

Example
float F(float a, float b)
{
  return a + b * 3.0;
}

The C standard states that 3.0 in this example has the type double and therefore the whole expression should be evaluated in double precision. However, when the ‑‑relaxed_fp option is used, 3.0 will be converted to float and the whole expression can be evaluated in float precision.

Caution

To set related options, choose:

Project>Options>C/C++ Compiler>Language 2 >Floating-point semantics