Code Composer Optimizer is a report of where the C2000 compiler optimizer omits the generation of code for an if block.
A test project is attached which uses the C2000 compiler v6.4.9, and when the Source interlist option was used from looking at the generated assembler have repeated the problem.
When the Optimization Level is set to off the assembler for the "nWords2Send += 160;" statement is generated:
.dwpsn file "../main.c",line 21,column 5,is_stmt,isa 0
;----------------------------------------------------------------------
; 21 | nWords2Send = (long) pQueue->Pending_In - (long) pQueue->Pending_Out ;
;----------------------------------------------------------------------
MOVL XAR5,*-SP[2] ; [CPU_] |21|
MOVL ACC,*+XAR5[0] ; [CPU_] |21|
SUBL ACC,*+XAR4[2] ; [CPU_] |21|
MOVL *-SP[10],ACC ; [CPU_] |21|
.dwpsn file "../main.c",line 27,column 5,is_stmt,isa 0
;----------------------------------------------------------------------
; 27 | if ( nWords2Send < 0 )
;----------------------------------------------------------------------
MOVL ACC,*-SP[10] ; [CPU_] |27|
BF $C$L1,GEQ ; [CPU_] |27|
; branchcc occurs ; [] |27|
.dwpsn file "../main.c",line 29,column 9,is_stmt,isa 0
;----------------------------------------------------------------------
; 29 | nWords2Send += 160 ; // Cyclic buffer roll
;----------------------------------------------------------------------
MOVB ACC,#160 ; [CPU_] |29|
ADDL ACC,*-SP[10] ; [CPU_] |29|
MOVL *-SP[10],ACC ; [CPU_] |29|
$C$L1:
.dwpsn file "../main.c",line 34,column 5,is_stmt,isa 0
However, when the optimization level is set to "0 Register Optimizations" the assembler for the "nWords2Send += 160;" statement is NOT generated:
.dwpsn file "../main.c",line 21,column 5,is_stmt,isa 0
;----------------------------------------------------------------------
; 21 | nWords2Send = (long) pQueue->Pending_In - (long) pQueue->Pending_Out ;
; 27 | if ( nWords2Send < 0 )
;----------------------------------------------------------------------
MOVL ACC,*+XAR4[0] ; [CPU_] |21|
SUBL ACC,*+XAR4[2] ; [CPU_] |21|
BF $C$L1,GEQ ; [CPU_] |21|
; branchcc occurs ; [] |21|
.dwpsn file "../main.c",line 29,column 9,is_stmt,isa 0
;----------------------------------------------------------------------
; 29 | nWords2Send += 160 ; // Cyclic buffer roll
;----------------------------------------------------------------------
$C$L1:
.dwpsn file "../main.c",line 34,column 5,is_stmt,isa 0
I haven't investigated with other optimization level settings, but this does appear to be a bug in the compiler optimizer.