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 CCS3.3 compiler optimization issue

Champs,

One of my customers enabled the Local (-o1) opt level in the CCS3.3 to save flash space but encountered with an error result issue  with the same C code.

The error comes from below statement:

iq10Temp.lData = _IQ10mpy(iq10Temp.lData,g_iq10PfcVolt.lData);

With P = iq10Temp.IData, the assembly code after optimization is:

 1074 000001e0 761F-         MOVW      DP,#_g_iq10PfcVolt
         000001e1 0000
    1075 000001e2 A9AC          MOVL      XT,P
    1076 000001e3 5605-         IMPYL     P,XT,@_g_iq10PfcVolt  ; |435|
         000001e4 0004
1077 000001e5 A9AC                 MOVL      XT,P                  ; |435|    
1078 000001e6 5663-         QMPYL     ACC,XT,@_g_iq10PfcVolt ; |435|
         000001e7 0004
1079 000001e8 5689          ASR64     ACC:P,#10             ; |435|

Obviously, there insert an additional instruction markered with red MOVL      XT,P , which leads to the incorrect multiply result because the desired non-variable XT has been modified after the red unexpected instruction.

Here comes the question, why this instruction added in the assembly code? How does the compiler do to this _IQ10mpy statement when local opt level enabled?

If the auxiliary register P is replaced by other registers, such as XAR4, this issue will also not exist, then what is the principle on allocating auxiliary register?

Thanks for your suggestion.

 

Best regards,

Ricky Zhang