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

CLA compiler generates inefficient code for comparison of unsigned short values

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Implemented
    • Icon: Medium Medium

      The attached test case contains this code ...

      extern uint16_t a, b;
      
      int fxn()
      {
          return a < b;
      }
      

      Build it ...

      % cl2000 --cla_support=cla1 --src_interlist file.cla
      

      Inspect the resulting assembly file to see ...

      ;----------------------------------------------------------------------
      ;   7 | return a < b;                                                          
      ;----------------------------------------------------------------------
              MMOVZ16   MR1,@_b               ; [CPU_FPU] |7| 
              MMOVZ16   MR2,@_a               ; [CPU_FPU] |7| 
              MLSL32    MR1,#16               ; [CPU_FPU] |7| 
              MLSL32    MR2,#16               ; [CPU_FPU] |7| 
              MLSR32    MR1,#16               ; [CPU_FPU] |7| 
              MLSR32    MR2,#16               ; [CPU_FPU] |7| 
              MCMP32    MR1,MR2               ; [CPU_FPU] |7| 
      

      The instruction MMOVZ16 zeros out the upper half of the register. Therefore, there is no need for the 4 shift instructions.

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

              Created:
              Updated:
              Resolved: