[Bug target/46631] New: Change operands order so we can use 16bit and instead of 32bit in thumb2
carrot at google dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 24 02:57:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46631
Summary: Change operands order so we can use 16bit and instead
of 32bit in thumb2
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: carrot@google.com
CC: carrot@google.com
Compile the following code with options -march=armv7-a -mthumb -Os
struct S {
int bi_buf;
int bi_valid;
};
int tz (struct S* p, int bits, int value)
{
if (p == 0) return 1;
p->bi_valid = bits;
p->bi_buf = value & ((1 << bits) - 1);
return 0;
}
GCC 4.6 generates:
00000000 <tz>:
0: 2301 movs r3, #1
2: b138 cbz r0, 14 <tz+0x14>
4: 408b lsls r3, r1
6: 6041 str r1, [r0, #4]
8: 3b01 subs r3, #1
a: ea03 0202 and.w r2, r3, r2 // A
e: 6002 str r2, [r0, #0]
10: 2000 movs r0, #0
12: 4770 bx lr
14: 4618 mov r0, r3
16: 4770 bx lr
Notice instruction A is 32 bit, if we change it to
and r2, r2, r3
then we can encode it as 16bit.
More information about the Gcc-bugs
mailing list