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

--- Comment #7 from Dominik Vogt <vogt at linux dot vnet.ibm.com> ---
The stage1 compiler does something wrong when compiling gcc/real.c (with
-fprofile-generate).  The function div_significands() (inlined into
do_divide()) returns a wrong result due to bad register usage in this loop:

-- snip --
  do
    {
      msb = u.sig[SIGSZ-1] & SIG_MSB;
      lshift_significand_1 (&u, &u);
    start:
      if (msb || cmp_significands (&u, b) >= 0)
        {
          sub_significands (&u, &u, b, 0);
          set_significand_bit (r, bit);
        }
    }
  while (--bit >= 0);
-- snip --

At loop entry ("start" label), r1 holds the highest 64 bits of the significand.
 The first pass through the loop seems to be correct; sub_significands() and
set_significand_bit() do the correct operations.  After that, r1 is decremented
by one as if it contained the variable "bit".  Later on r1 gets (eventually)
overwritten with zero.  After that, the loop always thinks that the remaining
significand is too smaller than b because its always zero.

In the end, the "result" of the division is one in the highest significand bit
and all other bits zero, eventually causing the observed assertion failure.

With a broken compiler (from stageprofile), the test program for triggering the
ICE is simply

-- snip --
int x = __DBL_MAX__;
-- snip --

All of this only happens on a Fedora 20 chroot for me.  I've tried to add
"-save-temps -dA -dP -fdump-rtl-all" to the OPT_FLAGS in the rpm spec file, but
then the package doesn't build at all.  Any hints how to get debug information
from the rembuild run is welcome.

Reply via email to