It has been observed that when the C absolute function, abs(), is called in C code, such as that below, the CCS compiler will not generate assembly code for that C abs() code when Optimization is set to "3 Interprocedure Optimizations":
et = Timestamp_get32();
if (abs(intvar1 - intvar2) > 1)
{
intvar2 = intvar1;
}
et = Timestamp_get32() - et - cal;
The first indication that assembly code for the C abs() function was not generated was when the elapsed time was zero only when the compiler Optimization was set to "3 Interprocedure Optimizations”.
Proof that the compiler does not generate assembly code for the C abs()code above is provided in the associated assembly code below. Note that a comment containing the C abs() code is given but no assembly code is generated for it:
;----------------------------------------------------------------------
; 215 | et = Timestamp_get32();
; 216 | if (abs(intvar1 - intvar2) > 1)
; 218 | intvar2 = intvar1;
;----------------------------------------------------------------------
LCR #_xdc_runtime_Timestamp_get32__E ; [CPU_] |215|
MOVW DP,#_et ; [CPU_U]
MOVL @_et,ACC ; [CPU_] |215|
;----------------------------------------------------------------------
; 220 | et = Timestamp_get32() - et - cal;
;----------------------------------------------------------------------
LCR #_xdc_runtime_Timestamp_get32__E ; [CPU_] |220|
The associated Debugger Disassembly code follows which also proves that no assembly code was generated for the C abs() code:
10a6bf: 7650FEDC LCR xdc_runtime_Timestamp_get32__F
10a6c1: 761F03C0 MOVW DP, #0x3c0
10a6c3: 1E04 MOVL @0x4, ACC
10a6c4: 7650FEDC LCR xdc_runtime_Timestamp_get32__F
QUESTION: Why is C code associated with the abs()function not included when compiled with the Optimization set to "3 Interprocedure Optimizations" in the CCS compiler?
Thank you,
Tim Ball
TDB Consulting