public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49799] New: gcc arm generates illegal sbfx instruction
@ 2011-07-21  7:40 carrot at google dot com
  2011-07-21 11:13 ` [Bug target/49799] " mikpe at it dot uu.se
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: carrot at google dot com @ 2011-07-21  7:40 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-06-24 23:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21  7:40 [Bug target/49799] New: gcc arm generates illegal sbfx instruction carrot at google dot com
2011-07-21 11:13 ` [Bug target/49799] " mikpe at it dot uu.se
2011-07-21 12:53 ` mikpe at it dot uu.se
2011-07-21 14:29 ` ramana at gcc dot gnu.org
2011-07-25  8:40 ` [Bug rtl-optimization/49799] " carrot at google dot com
2011-07-25  9:03 ` rearnsha at gcc dot gnu.org
2011-07-25  9:26 ` carrot at google dot com
2011-07-25  9:46 ` rearnsha at gcc dot gnu.org
2011-07-26  2:53 ` carrot at google dot com
2011-07-29  1:28 ` carrot at gcc dot gnu.org
2011-07-29  8:37 ` carrot at gcc dot gnu.org
2011-08-02  9:37 ` carrot at google dot com
2015-06-24 23:28 ` ramana at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).