This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C2000 V5.2.5 to V5.2.11 optimizer bug



Hello,
 
I'v got wrong ASM code compiling following statement with -o1 optimization (C-compiler V5.2.11):
 
  SysSup_Fault2 = (((((((((((((((IEM_MCP_C0_B.shift_irm4 |
    IEM_MCP_C0_B.SysSupFlt_HvDcUnplug) | ((uint32_T)IEM_MCP_C0_B.FaultFilt_evgd))
    | ((uint32_T)IEM_MCP_C0_B.FaultFilt_jtcz)) | ((uint32_T)
    IEM_MCP_C0_B.shift_fwl4)) | ((uint32_T)(IEM_MCP_C0_B.Rx_SRS_00 ? 3072 : 0)))
    | IEM_MCP_C0_B.Fault_TrqReq) | IEM_MCP_C0_B.Fault_TrqLim) |
    IEM_MCP_C0_B.Fault_CheckMotorSpd) | (((uint32_T)IEM_MCP_C0_B.UnitDelay3_hup5)
    << 2)) | IEM_MCP_C0_B.Fault_UBat) | ((uint32_T)
    IEM_MCP_C0_B.Fault_SpdUnreliable)) | IEM_MCP_C0_B.shift_gfts) |
                     IEM_MCP_C0_B.shift_eryt) | (((uint32_T)IEM_MCP_C0_B.Flt32) <<
    30)) | ((IEM_MCP_C0_B.Tlbx_TransientFilterValidB_djuq.BitwiseOperator == 3U)
            ? 3145728UL : 0UL)) | 357913937UL;
 
The bug seems to be fixed with C-compiler V5.2.12
 
In  Defect History of 5.2.12 is written:
------------------------------------------------------------------------------
FIXED  SDSCM00039478
------------------------------------------------------------------------------
Summary            : Compiler generates incorrect code when optimization is enabled
Fixed in           : 5.2.12
Severity           : S2 - Major
Affected Component : Optimizer
 
Is there a detailed explanation of fix SDSCM00039478 available?
I need to know if the fix SDSCM00039478 made my code working or if this is just a side effect!
 
regards
Konrad Bertignoll
  • If you are compiling for C28x, and use --float_support=fpu32 or --float_support=fpu64, and the .asm file resulting from compilation contains "MAXF32||MOV32" or "MINF32||MOV32" instructions, then SDSCM00039478 may be relevant.

  • Statement wich leads to wrong ASM code:
     
    SysSup_Fault2 = (((((((((((((((IEM_MCP_C0_B.shift_irm4 | IEM_MCP_C0_B.SysSupFlt_HvDcUnplug) | ((uint32_T)IEM_MCP_C0_B.FaultFilt_evgd))
    | ((uint32_T)IEM_MCP_C0_B.FaultFilt_jtcz)) | ((uint32_T)  IEM_MCP_C0_B.shift_fwl4)) | ((uint32_T)(IEM_MCP_C0_B.Rx_SRS_00 ? 3072 : 0)))
    | IEM_MCP_C0_B.Fault_TrqReq) | IEM_MCP_C0_B.Fault_TrqLim) | IEM_MCP_C0_B.Fault_CheckMotorSpd) | (((uint32_T)IEM_MCP_C0_B.UnitDelay3_hup5)
     << 2)) | IEM_MCP_C0_B.Fault_UBat) | ((uint32_T) IEM_MCP_C0_B.Fault_SpdUnreliable)) | IEM_MCP_C0_B.shift_gfts) |  IEM_MCP_C0_B.shift_eryt) | (((uint32_T)IEM_MCP_C0_B.Flt32) << 30)) | ((IEM_MCP_C0_B.Tlbx_TransientFilterValidB_djuq.BitwiseOperator == 3U) ? 3145728UL : 0UL)) | 357913937UL;

    If I insert the above statement 2 times in the C code the generated ASM code is correct!

    Compiler 5.2.11 NOK:
    0x310ABA: Result is saved to SysSup_Fault2 (@62)
    0x310ACE: OR with 0x1555 is done after Result is saved to SysSup_Fault2 (Compiler Bug!)

    Compiler 5.2.12 OK:

    0x310BD4: Result is saved to SysSup_Fault2 (@62) after OR with 0x1555 (This is OK)

     

  • It is unlikely you are experiencing SDSCM00039478.  

    For us to understand what is happening, we need to reproduce this possible bug ourselves.  Please submit a test case as described in the last part of the forum guidelines.

    Thanks and regards,

    -George

  • We received a test case through other channels.  Thank you.

    konrad bertignoll said:
    Is there a detailed explanation of fix SDSCM00039478 available?

    It involves the optimization phase of the compiler automatically generating __f32_min_idx and __f32_max_idx intrinsics, and how those intrinsics interact with subsequent if statements.

    konrad bertignoll said:
    I need to know if the fix SDSCM00039478 made my code working or if this is just a side effect!

    Those intrinsics are not automatically generated in your case.  Thus, the fix for SDSCM00039478 has nothing to do with your situation.  Some other change in version 5.2.12 causes your problem to disappear.  

    Thanks and regards,

    -George

  • Hello,

    have you analyzed the root cause of this very serious problem?

    We need a fix of the problem for compiler 5.2.5 asap

    Konrad

     

     

  • With some difficulty, I reproduced the problem.  That allowed me to file SDSCM00046812 in the SDOWP system.  In turn, this enables development engineering to work out the cause of the problem.  You can follow this issue with the SDOWP link below in my signature.

    Thanks and regards,

    -George