Compiler intrinsic _itof ignores truncation of its argument

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Medium

      If the intrinsic _itof is passed an argument that is truncated to a size smaller than 32 bits, the compiler may incorrectly discard the truncation. This truncation can occur with a cast to short or a bit-mask to the lower 16 bits.

      For example:

      /*
         build with
         cl6x -mv6600 -O3 -s file.cpp
      */
      #include <stdint.h>
      float bug(uint32_t a, uint32_t b)
      {      
          const uint32_t lo16 = b & 0x0000FFFFU;
          return _itof(lo16);
      }
      

      You'll get

      bug:
      
                 RETNOP          B3,4 
                 MV      .L1X    B4,A4 
      

      The & 0x0000ffff is ignored. So, if the input value has bits set in the upper 16-bits, they are incorrectly part of the result returned from the function.

            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-3729 - Compiler intrinsic _itof ignores tr...
                SYNCHRONIZED
                • Last Sync Date: