Truncation of unsigned to byte is not translated to uxtb insn, but truncation
to short is translated to uxth.
invocation:
gcc -mcpu=cortex-m3 -mthumb -O3 -S a.c
code (a.c):
unsigned a();
extern unsigned b;
main()
{
b = a() & 0xFF;
b = (unsigned char)a();
b = a() & 0xFFFF;
b = (unsigned short)a();
}
resulting asm fragment (a.s):
[...]
bl a
and r0, r0, #255
str r0, [r4, #0]
bl a
uxtb r0, r0
str r0, [r4, #0]
bl a
uxth r0, r0
str r0, [r4, #0]
bl a
uxth r0, r0
str r0, [r4, #0]
[...]
--
Summary: unsigned int var; (var & 0xFF) not translated to uxtb
insn in Thumb mode
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mirq-gccboogs at rere dot qmqm dot pl
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-none-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43461