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

Reply via email to