Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-11845

For a float if statement followed by divide, compiler generated code performs divide first

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Not Prioritized Not Prioritized
    • Code Generation Tools
    • CODEGEN-12700
    • Hide
      ARMCLANG_4.0.0.LTS
      ARMCLANG_3.2.2.LTS
      Show
      ARMCLANG_4.0.0.LTS ARMCLANG_3.2.2.LTS
    • default
    • Hide
      This functionality is implemented as a new feature in the 4.0.0.LTS release of the tools via "-ffp-exception-behavior=strict|maytrap" option which can be used to prevent floating point exceptions by preventing floating point operations from being moved outside of conditional control flow.

      Please see the release notes for more information on how to use this option:
      https://software-dl.ti.com/codegen/esd/cgt_public_sw/ARM_LLVM/4.0.0.LTS/README.html#suppress-floating-point-speculation-with--ffp-exceptions-compiler-option
      Show
      This functionality is implemented as a new feature in the 4.0.0.LTS release of the tools via "-ffp-exception-behavior=strict|maytrap" option which can be used to prevent floating point exceptions by preventing floating point operations from being moved outside of conditional control flow. Please see the release notes for more information on how to use this option: https://software-dl.ti.com/codegen/esd/cgt_public_sw/ARM_LLVM/4.0.0.LTS/README.html#suppress-floating-point-speculation-with--ffp-exceptions-compiler-option

      The related test case has these lines ...

        if(float1 > CP_MIN)
        {
          f_array[1u] = (1.f / *f_Info);
        }
      

      Code generated by the compiler performs the division before the if statement. For values where that divide causes an FPU exception to be raised, the if statement should keep the divide from happening. But because the divide happens no matter what, the FPU exception is incorrectly raised for those values.

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: