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

Optimizer drops part of a compound conditional expression controlling a loop

    XMLWordPrintable

Details

    • Bug
    • Status: Fixed
    • Medium
    • Resolution: Fixed

    Description

      The attached test case contains this code ...

          for (u32 i = 0; (i < arrSize && i < CByteAligner::bitsToOctetsRoundUp(tbSize)); i++) /* PROBLEM FOR LOOP */ 
              localMem[i] = p_corruptedPdu[i];
      

      The generated code accounts for the i < CByteAligner::bitsToOctetsRoundUp(tbSize)) part of the condition controlling the loop. But not the i < arrSize part.

      Build it ...

      % cl6x -@options.txt file.cpp
      

      Inspect the compiler generated comments for the problem loop.

      ;* 128211       -----------------------    memset(&localMem, 0, 16u);
      ;* 128212       -----------------------    K$13 = tbSize+7u;
      ;* 128212       -----------------------    if ( !(C$5 = K$13>>3) ) goto g4;
      ;**     -----------------------    U$21 = p_corruptedPdu;
      ;* 128213       -----------------------    L$1 = C$5;
      ;**     -----------------------    U$23 = &localMem[0];
      ;**     -----------------------    #pragma MUST_ITERATE(1, 16, 1)
      ;**     -----------------------    #pragma LOOP_FLAGS(4096u)
      ;**     -----------------------g3:
      ;* 128213       -----------------------    *U$23++ = *U$21++;
      ;* 128212       -----------------------    if ( L$1 = L$1-1 ) goto g3;
      ;**     -----------------------g4:
      

      L$1 controls this loop. It down counts from CByteAligner::bitsToOctetsRoundUp(tbSize)) to 0. But this ignores the i < 16 part of the loop condition.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: