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

C28 saturation optimization for if/ternary max check generates incorrect results for values above max limit for fpu64 with volatile variable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-12673
    • Hide
      C2000_22.6.0.LTS
      C2000_21.6.0.LTS
      Show
      C2000_22.6.0.LTS C2000_21.6.0.LTS
    • Hide
      C2000_25.3.0.LTS*
      C2000_22.6.2.LTS*
      C2000_21.6.2.LTS*
      Show
      C2000_25.3.0.LTS* C2000_22.6.2.LTS* C2000_21.6.2.LTS*
    • default
    • Use --opt_level=off or avoid using volatile variables in the compare.

      The C28 Compiler's saturation optimization for if/ternary max check generates incorrect results for volatile variable values above a constant max limit.

      The issue occurs with:
      --float_support=fpu64
      --opt_level=0-4
      volatile compares involving doubles and floating point constants
      volatile variable's value is greater than a constant max limit

      Example C code::

             volatile double x_volatile;
             if(x_volatile > 4) x_volatile=4;
             x_volatile = (x_volatile > 4) ? 4 : x_volatile;
      

      In the generated assembly, the GEQ condition code should instead be LT:

              MOV32     *-SP[4],R0L         
              MOV32     *-SP[2],R0H       
              MOV32     R0H,*-SP[2]      
              MOV32     R0L,*-SP[4]      
              MINF64    R0,#16400       
              NOP       ; [CPU_ALU] 
              MOV32     R0H,*-SP[2],GEQ  <-- Should be LT  
              MOV32     R0L,*-SP[4],GEQ   <-- Should be LT     
              MOV32     *-SP[4],R0L          
              MOV32     *-SP[2],R0H        
              MOV32     R0H,*-SP[2]        
              MOV32     R0L,*-SP[4]        
      

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

              Created:
              Updated:
              Resolved: