public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/65649] New: gcc generates overlarge constants for microblaze-linux-gnu
@ 2015-04-01 11:44 dhowells at redhat dot com
  2015-04-01 11:48 ` [Bug target/65649] " dhowells at redhat dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dhowells at redhat dot com @ 2015-04-01 11:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65649

            Bug ID: 65649
           Summary: gcc generates overlarge constants for
                    microblaze-linux-gnu
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhowells at redhat dot com

Whilst compiling libgcc for microblaze-linux-gnu, gcc produces overlarge
constants that don't fit into a 32-bits (microblaze is a 32-bit arch), eg:

    addik    r23,r0,0xb746a0003f800000

the assembler complains about these:

    _powisf2.s:71: Fatal error: operand must be a constant or a label

if it is hosted on a 32-bit arch (eg. i386) but not if it's hosted on a 64-bit
arch (eg. x86_64).  This is logged here:

    https://sourceware.org/bugzilla/show_bug.cgi?id=18189

However, gcc shouldn't be producing these at all.

Reducing the preprocessed C to the bare function gives:

    float __powisf2 (float x, int m)
    {
      unsigned int n = m < 0 ? -m : m;
      float y = n % 2 ? x : 1;
      while (n >>= 1)
    {
      x = x * x;
      if (n % 2)
        y = y * x;
    }
      return m < 0 ? 1/y : y;
    }

Reducing it still further to:

    float __powisf2 (float x, int m)
    {
      unsigned int n = m < 0 ? -m : m;
      float y = n % 2 ? x : 1;
      return y;
    }

gives the error _only_ if -g is supplied.  Looking at the assembly output of
this, the dodgy instruction is now:

        addik   r3,r0,0xb745e0003f800000

with -g and:

        addik   r3,r0,0x3f800000

without.

The compilation line is:

/root/cross-gcc/gcc-5.0.0-20150319/microblaze-linux-gnu/gcc/xgcc
-B/root/cross-gcc/gcc-5.0.0-20150319/microblaze-linux-gnu/gcc/
-B/usr/microblaze-linux-gnu/bin/ -B/usr/microblaze-linux-gnu/lib/ -O2 -fPIC
-fbuilding-libgcc -fno-exceptions -fno-stack-protector -fvisibility=hidden -o
_powisf2.o -c _powisf2.i --save-temps -g


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

end of thread, other threads:[~2023-07-07  7:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 11:44 [Bug target/65649] New: gcc generates overlarge constants for microblaze-linux-gnu dhowells at redhat dot com
2015-04-01 11:48 ` [Bug target/65649] " dhowells at redhat dot com
2015-04-01 11:55 ` dhowells at redhat dot com
2015-04-21  8:30 ` nickc at redhat dot com
2015-04-21 11:21 ` nickc at redhat dot com
2015-04-21 15:28 ` nickc at redhat dot com
2020-05-07 11:56 ` jakub at gcc dot gnu.org
2020-07-23  6:51 ` rguenth at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2022-06-28 10:31 ` jakub at gcc dot gnu.org
2023-07-07  7:27 ` rguenth 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).