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

Analyze loop for better performance

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Implement
    • Icon: Not Prioritized Not Prioritized
    • Code Generation Tools
    • CODEGEN-7929
    • C2000_20.2.1.LTS
    • default
    • With BU agreement that this is too narrow of a use case for doing any feature work, rejecting since we will never address.

      The attached file contains this function ...
       

      void
      Gpio_example1(void)
      { 
          int j;
          for(;;)
          {
              for(j=0;j<30;j++)
              {
                  GpioDataRegs.GPADAT.all = tab[j];
              }
          }
      }
      

      Build it ...
       

      % cl2000 -o3 --float_support=fpu32 -s try1.c
      

      Inspect the resulting assembly file to see ...

      ;***  	-----------------------    #pragma LOOP_FLAGS(4096u)
      $C$L1:    
      ;***	-----------------------g2:
      ;***  	-----------------------    U$7 = &tab[0];
      ;** 10653	-----------------------    _j = 0;
      ;***  	-----------------------    #pragma MUST_ITERATE(30, 30, 30)
      ;***  	-----------------------    #pragma LOOP_FLAGS(4096u)
              MOVL      XAR4,#_tab            ; [CPU_ARAU] 
      	.dwpsn	file "try1.c",line 10653,column 13,is_stmt,isa 0
              MOVB      AL,#0                 ; [CPU_ALU] |10653| 
      $C$L2:    
      ;***	-----------------------g3:
      ;** 10655	-----------------------    GpioDataRegs._GPADAT._all = *U$7++;
      ;** 10653	-----------------------    if ( (++_j) >= 30 ) goto g2;
      	.dwpsn	file "try1.c",line 10655,column 13,is_stmt,isa 0
              MOVL      XAR6,*XAR4++          ; [CPU_ALU] |10655| 
      	.dwpsn	file "try1.c",line 10653,column 17,is_stmt,isa 0
              ADDB      AL,#1                 ; [CPU_ALU] |10653| 
              MOVW      DP,#_GpioDataRegs     ; [CPU_ARAU] 
              CMPB      AL,#30                ; [CPU_ALU] |10653| 
      	.dwpsn	file "try1.c",line 10655,column 13,is_stmt,isa 0
              MOVL      @$BLOCKED(_GpioDataRegs),XAR6 ; [CPU_FPU] |10655| 
      	.dwpsn	file "try1.c",line 10653,column 17,is_stmt,isa 0
              B         $C$L1,GEQ             ; [CPU_ALU] |10653| 
              ; branchcc occurs ; [] |10653| 
      ;** 10653	-----------------------    goto g3;
              B         $C$L2,UNC             ; [CPU_ALU] |10653| 
              ; branch occurs ; [] |10653| 
      

      Notice the branches back to the top of the loop in the auto-generated comments. They branch back to the incorrect label. goto g2 and goto g3 should be swapped.  The assembly code branches make the same error.
       

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

              Created:
              Updated:
              Resolved: