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

Loop over array, preceded by shuffle of the array using scalar temp repeatedly, may produce incorrect results

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-5032
    • Hide
      C2000_16.9.0.LTS
       ARM_16.9.0.LTS
       ARM_18.1.0.LTS
      Show
      C2000_16.9.0.LTS  ARM_16.9.0.LTS  ARM_18.1.0.LTS
    • Hide
      ARM_18.12.0.LTS
       C2000_18.12.0.LTS
      Show
      ARM_18.12.0.LTS  C2000_18.12.0.LTS
    • The test case uses the same temp, nTemp, repeatedly in the shuffle function. Using different temps for each assignment will avoid the problem. Using "#pragma UNROLL(1)" to inhibit unrolling of the affected loops may also avoid the problem.
    • Hide
      The problem case looks something like

      x = a[0]
      a[1] = x
      x = a[2]
      a[3] = x
      for (i = 0; i < N; i++) {
        a[i] = ...
        ... a[i] ...
      }

      It shuffles data in an array a[] using the scalar x, then loops over array a[]. This particular arrangement, with the right optimisations, will do the wrong thing with the shuffle code. The wrong thing is part of optimising the loop, so both parts are required for there to be a problem. A workaround is to use a separate scalar variable for each assignment in the shuffle, ie, "x1 = a[0]; a[1] = x1" and "x2 = a[2]; a[3] = x2".
      Show
      The problem case looks something like x = a[0] a[1] = x x = a[2] a[3] = x for (i = 0; i < N; i++) {   a[i] = ...   ... a[i] ... } It shuffles data in an array a[] using the scalar x, then loops over array a[]. This particular arrangement, with the right optimisations, will do the wrong thing with the shuffle code. The wrong thing is part of optimising the loop, so both parts are required for there to be a problem. A workaround is to use a separate scalar variable for each assignment in the shuffle, ie, "x1 = a[0]; a[1] = x1" and "x2 = a[2]; a[3] = x2".

      Loop over array, preceded by shuffle of the array using scalar temp repeatedly, may produce incorrect results

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

              Created:
              Updated:
              Resolved: