-
Enhancement
-
Resolution: Implemented
-
Low
-
Code Generation Tools
-
CODEGEN-7111
-
MSP430_18.12.2.LTS
-
MSP430_20.2.0.LTS*
-
default
The attached test has this line ...
return a | __swap_bytes(b);
a and b are of type unsigned char. Build it with optimization ...
% cl430 -vmspx -o -s try1.c
... and the resulting assembly is not very good.
;** 7 ----------------------- return (unsigned)a|(unsigned)b>>8|(unsigned)b<<8; .dwpsn file "try1.c",line 7,column 5,is_stmt,isa 0 MOV.B &a+0,r15 ; [] |7| MOV.B &b+0,r12 ; [] |7| SWPB r12 ; [] |7| MOV.B r12,r12 ; [] |7| OR.W r12,r15 ; [] |7| MOV.B &b+0,r12 ; [] |7| RPT #8 || RLAX.W r12 ; [] |7| OR.W r15,r12 ; [] |7|
Build it with no optimization ...
% cl430 -vmspx -ooff -s try1.c
... and the resulting assembly is much better ...
;---------------------------------------------------------------------- ; 7 | return a | __swap_bytes(b); ;---------------------------------------------------------------------- MOV.B &a+0,r15 ; [] |7| MOV.B &b+0,r12 ; [] |7| SWPB r12 ; [] |7| OR.W r15,r12 ; [] |7|