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

Floating point comparison that fits min/max-index pattern can produce incorrect code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-6911
    • Hide
      C2000_18.1.0.LTS
       C2000_18.12.0.LTS
      Show
      C2000_18.1.0.LTS  C2000_18.12.0.LTS
    • Hide
      C2000_20.2.0.LTS*
       C2000_18.12.5.LTS
      Show
      C2000_20.2.0.LTS*  C2000_18.12.5.LTS
    • Interpose some other statement that isn't a float-to-float assignment between the two float-to-float assignments under the IF.
    • Hide
      Code that looks like

      if (A < B) {
          B = A
          X = Y
          something_else()
      }

      where A, B, X, and Y are all float or double variables and the comparison is < or >, may execute the "something_else()" not only when A<B, but also when A==B, when compiled with optimisation.

      The IF and the two assignments match the pattern for a C2000 intrinsic designed for the min-index and max-index operation -- finding not just the maximum or minimum value, but also its position in an array. The compiler will absorb them into the intrinsic call, but then mishandle the conditional for anything else in the IF block.

      If the "something_else" part is empty -- the block contains only the two assignments -- then there won't be a problem. Otherwise, the assignments will happen only when A<B, but the "something_else" will happen when A<B or A==B.
      Show
      Code that looks like if (A < B) {     B = A     X = Y     something_else() } where A, B, X, and Y are all float or double variables and the comparison is < or >, may execute the "something_else()" not only when A<B, but also when A==B, when compiled with optimisation. The IF and the two assignments match the pattern for a C2000 intrinsic designed for the min-index and max-index operation -- finding not just the maximum or minimum value, but also its position in an array. The compiler will absorb them into the intrinsic call, but then mishandle the conditional for anything else in the IF block. If the "something_else" part is empty -- the block contains only the two assignments -- then there won't be a problem. Otherwise, the assignments will happen only when A<B, but the "something_else" will happen when A<B or A==B.

      Floating point comparison that fits min/max-index pattern can produce incorrect code

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

              Created:
              Updated:
              Resolved: