This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/49799] New: gcc arm generates illegal sbfx instruction
- From: "carrot at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 21 Jul 2011 07:40:00 +0000
- Subject: [Bug target/49799] New: gcc arm generates illegal sbfx instruction
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49799
Summary: gcc arm generates illegal sbfx instruction
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: carrot@google.com
Host: linux
Target: armeabi
Compile the following code with options -march=armv7-a -O2
extern __inline int bar(int a)
{
int tmp;
if (a <= 0) a ^= 0xFFFFFFFF;
return tmp - 1;
}
void foo(short *K)
{
short tmp;
short *pptr, P[14];
pptr = P;
tmp = bar(*K);
*pptr = (*K << tmp) >> 16;
if (*P < tmp)
*K++ = 0;
}
gcc 4.7 generates
foo:
ldrsh r3, [r0, #0]
sbfx r3, r3, #17, #16 // A
sxth r3, r3
cmn r3, #1
movlt r3, #0
strlth r3, [r0, #0] @ movhi
bx lr
The sbfx instruction is illegal since the bit position + width > 32.
Although the source code is ill formed (function bar returns undefined value),
compiler should never generate illegal instructions.
gcc4.6 has the same problem.