-
Bug
-
Resolution: Won't Fix
-
Not Prioritized
-
Code Generation Tools
-
CODEGEN-9045
-
C2000_21.6.0.LTS
-
default
-
No indication there is a bug. Assembly will vary between optimized and unoptimized code, as with any code compiled with different option sets.
The attached file has these lines ...
struct bit_field_tag { uint32_t u8 : 8; uint32_t u24 : 24; } global_bit_field; uint32_t fxn() { return global_bit_field.u24; }
Build it ...
% cl2000 -s bf_bug.c
Inspect the resulting assembly to see these lines.
;---------------------------------------------------------------------- ; 8 | uint32_t fxn() { return global_bit_field.u24; } ;---------------------------------------------------------------------- MOVW DP,#_global_bit_field ; [CPU_ARAU] CLRC SXM ; [CPU_ALU] MOVL ACC,@_global_bit_field ; [CPU_ALU] |8| SFR ACC,8 ; [CPU_ALU] |8| ANDB AH,#255 ; [CPU_ALU] |8|
The ANDB should not be present. For confirmation, build the same code with optimization ...
% cl2000 -s -o bf_bug.c
This generates ...
;*** 8 ----------------------- return *&global_bit_field>>8; MOVW DP,#_global_bit_field ; [CPU_ARAU] CLRC SXM ; [CPU_ALU] .dwpsn file "bf_bug.c",line 8,column 18,is_stmt,isa 0 MOVL ACC,@_global_bit_field ; [CPU_ALU] |8| SFR ACC,8 ; [CPU_ALU] |8|
Note the ANDB is not present.