Incorrect results from left-shift paired with right-shift-by-16-or-24 expressions at -O2/-O3

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Urgent
    • Code Generation Tools
    • CODEGEN-15855
    • Hide
      C29_1.0.2.LTS
      C29_2.2.1.LTS
      Show
      C29_1.0.2.LTS C29_2.2.1.LTS
    • Hide
      C29_2.2.2.LTS*
      C29_3.0.0.LTS*
      C29_1.0.3.LTS*
      Show
      C29_2.2.2.LTS* C29_3.0.0.LTS* C29_1.0.3.LTS*
    • default
    • Hide
      - Compile affected code at -O1 or lower.
      - Avoid left-shift immediately followed by a fixed right-shift of 16 or 24 bits.
      - Wrap the left or right shift value in a volatile variable.
      Show
      - Compile affected code at -O1 or lower. - Avoid left-shift immediately followed by a fixed right-shift of 16 or 24 bits. - Wrap the left or right shift value in a volatile variable.

      At the -O[s,z,2,3] optimization level, combinations of immediate left shift and right shift expressions of the form (x << N) >> 16 or (x << N) >> 24 where N is a immediate between 0-31 and x is any 32 bit value such as 'unsigned int' or 'int' may result in erroneous values.

      Example Source:

      // With the value of in being 0x2000
      int shift_off_13(int in) {
          int x = in << 13;
          return x >> 16;
      }

      The resulting value will become 1 instead of the correct value of 0x400.

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

              Created:
              Updated:
              Resolved:

                Connection: Intermediate to External PROD System
                EXTSYNC-6853 - Incorrect results from left-shift p...
                SYNCHRONIZED
                • Last Sync Date: