public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jk at tools dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/11965] New: On SPARC, gcc produces invalid assembler code for a shift << 32 operation
Date: Mon, 18 Aug 2003 12:41:00 -0000	[thread overview]
Message-ID: <20030818124133.11965.jk@tools.de> (raw)

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11965

           Summary: On SPARC, gcc produces invalid assembler code for a
                    shift << 32 operation
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jk at tools dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8

GCC 3.3 on Solaris SPARC produces invalid assembler code, for shift operator
shifting 32 bits.

GCC 3.3 is compiled to use the system's assembler, /usr/ccs/bin/as


To reproduce the issue (admitted, this code has undefined behaviour):

% cat shift.c

#if __GNUC__
#define ATTR_ALWAYS_INLINE __attribute__ ((__always_inline__))
#else
#define ATTR_ALWAYS_INLINE
#endif


static ATTR_ALWAYS_INLINE unsigned
put_bits(int n, unsigned int value)
{
        return value << n;
}

main()
{
        unsigned val = 1;
        int i;

        for (i = 0; i < 4; i++)
                val = put_bits(32, val);

        printf("val=%x\n", val);
}

% gcc -O3 -mcpu=ultrasparc -o shift shift.c
/usr/ccs/bin/as: "/tmp/cc0VFu29.s", line 20: error: shift count negative or too
big: 32


Looking at the generated assembler source...

% gcc -O3 -mcpu=ultrasparc -S shift.c

... there's a shift instruction with a constant shift count of 32, where the
immediate shift count is restricted to the range 0 .. 31 on SPARC:

       sll     %o1, 32, %o1


The same code used to compile with gcc 3.2 and erlier, and it does compile with
gcc 3.3 at optimization level -O2 or when option -mcpu=ultrasparc is not used.


             reply	other threads:[~2003-08-18 12:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-18 12:41 jk at tools dot de [this message]
2003-08-18 17:35 ` [Bug c/11965] " falk at debian dot org
2003-08-19 20:04 ` martin at netbsd dot org
2003-08-23  1:22 ` dhazeghi at yahoo dot com
2003-08-23 14:24 ` [Bug target/11965] [3.3/3.4 Regression] " pinskia at gcc dot gnu dot org
2003-09-09 14:51 ` [Bug target/11965] [3.3/3.4 Regression] " ebotcazou at gcc dot gnu dot org
2003-09-10 12:59 ` cvs-commit at gcc dot gnu dot org
2003-09-10 13:04 ` cvs-commit at gcc dot gnu dot org
2003-09-10 13:05 ` ebotcazou at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030818124133.11965.jk@tools.de \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).