Tool/software: Code Composer Studio
Given the following function:
extern unsigned char src, dst;
void func(void)
{
dst &= ~src;
}
The CGT compiler produces the following output:
;*****************************************************************************
;* FUNCTION NAME: func *
;* *
;* Regs Modified : SP,SR,r15 *
;* Regs Used : SP,SR,r15 *
;* Local Frame Size : 0 Args + 0 Auto + 0 Save = 0 byte *
;*****************************************************************************
func:
;* --------------------------------------------------------------------------*
.dwcfi cfa_offset, 4
.dwcfi save_reg_to_mem, 16, -4
;** 6 ----------------------- src &= dst^0xff;
.dwpsn file "../src/bic.c",line 6,column 5,is_stmt,isa 0
MOV.W #255,r15 ; [] |6|
XOR.B &dst+0,r15 ; [] |6|
AND.B r15,&src+0 ; [] |6|
;** ----------------------- return;
$C$DW$4 .dwtag DW_TAG_TI_branch
.dwattr $C$DW$4, DW_AT_low_pc(0x00)
.dwattr $C$DW$4, DW_AT_TI_return
RETA ; []
; []
.dwattr $C$DW$3, DW_AT_TI_end_file("../src/bic.c")
.dwattr $C$DW$3, DW_AT_TI_end_line(0x07)
.dwattr $C$DW$3, DW_AT_TI_end_column(0x01)
.dwendentry
.dwendtag $C$DW$3
This should instead just produce `BIC.B &src,&dst`. This doesn't seem like much of a problem except that this particular construct is very common in our program for clearing port bits and the compiler generated code is 4x the size of the trivially optimal version.