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

--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
cse.c:fold_rtx is miscompiled by the stage2 compiler, more precisely in:

          if (const_arg1 != 0 && CONST_INT_P (const_arg1)
              && INTVAL (const_arg1) < 0
              /* This used to test

                 -INTVAL (const_arg1) >= 0

                 But The Sun V5.0 compilers mis-compiled that test.  So
                 instead we test for the problematic value in a more direct
                 manner and hope the Sun compilers get it correct.  */
              && INTVAL (const_arg1) !=
                ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT - 1))
              && REG_P (folded_arg1))
            {
              rtx new_const = GEN_INT (-INTVAL (const_arg1));

the -INTVAL is miscompiled:

=> 0x00a94d58 <+4884>:  subcc  %g0, %o3, %o2
   0x00a94d5c <+4888>:  clr  %o0
   0x00a94d60 <+4892>:  call  0x35044c <gen_rtx_CONST_INT(machine_mode, long
long)>
   0x00a94d64 <+4896>:  subc  %g0, %o2, %o1

%o2 is wrongly clobbered by the first subtraction.

Reply via email to