Fix twolf -funroll-loops -O3 miscompilation (a semi-latent web.c bug)

Steven Bosscher stevenb.gcc@gmail.com
Tue Nov 27 23:59:00 GMT 2012


On Wed, Nov 28, 2012 at 12:53 AM, Steven Bosscher wrote:
> On Wed, Nov 28, 2012 at 12:47 AM, Eric Botcazou wrote:
>>> Count me in, too.  So let's avoid it:
>>>
>>>         * gcse.c (struct reg_use): Remove unused struct.
>>>         (gcse_emit_move_after): Do not create REG_EQUAL notes that reference
>>> the SET_DEST of the instruction the note would be attached to.
>>
>> OK (with PR rtl-optimization/55006) if it passes bootstrap & regtest, thanks.
>
> Thanks for the quick review.
>
>
>>> And perhaps a bit in emit-rtl.c for good measure? I'll see if/where
>>> this causes breakage...
>>
>> I think this would need to be wrapped in a #ifdef ENABLE_CHECKING/#endif pair.
>
> Well, let me first try to make it pass some set of tests. This breaks
> the compiler in too many places to name right now. Here's the first of
> what's probably going to be a whole series of patches if I keep
> hitting this internal_error as often as I am now in my set of cc1-i
> files...
>
> I know: ChangeLog, testing and all that. That's not the point yet.
> This is just a brain dump, to get this saved in some places safer than
> the compile farm or (worse) my head ;-)

And another one:

Index: cprop.c
===================================================================
--- cprop.c     (revision 193394)
+++ cprop.c     (working copy)
@@ -776,7 +776,8 @@ try_replace_reg (rtx from, rtx to, rtx i
       /* If we've failed perform the replacement, have a single SET to
         a REG destination and don't yet have a note, add a REG_EQUAL note
         to not lose information.  */
-      if (!success && note == 0 && set != 0 && REG_P (SET_DEST (set)))
+      if (!success && note == 0 && set != 0 && REG_P (SET_DEST (set))
+         && ! reg_mentioned_p (SET_DEST (set), src))
        note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
     }



This one's for an interesting case of note, of a kind I've never seen
before. Had to share this gem of a note :-)

Ciao!
Steven


Breakpoint 1, internal_error (gmsgid=0x11455f8 "self-reference in
REG_EQUAL or REG_EQUIV note!\n") at ../../trunk/gcc/diagnostic.c:1087
1087      va_start (ap, gmsgid);
(gdb) up
#1  0x0000000000709dea in set_unique_reg_note (insn=0x7ffff507b3a8,
kind=REG_EQUAL, datum=0x7ffff528c2e0) at
../../trunk/gcc/emit-rtl.c:5001
5001            internal_error ("self-reference in REG_EQUAL or
REG_EQUIV note!\n");
(gdb)
#2  0x0000000000f608c4 in try_replace_reg (from=0x7ffff5301c60,
to=0x7ffff62e5460, insn=0x7ffff507b3a8) at ../../trunk/gcc/cprop.c:780
780             note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
(gdb) l
775
776           /* If we've failed perform the replacement, have a single SET to
777              a REG destination and don't yet have a note, add a
REG_EQUAL note
778              to not lose information.  */
779           if (!success && note == 0 && set != 0 && REG_P (SET_DEST (set)))
780             note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
781         }
782
783       if (set && MEM_P (SET_DEST (set)) && reg_mentioned_p (from,
SET_DEST (set)))
784         {
(gdb) p debug_rtx (set)
(set (reg/v:SI 173 [ xsize ])
    (if_then_else:SI (ge (reg:CCGC 17 flags)
            (const_int 0 [0]))
        (reg/v:SI 173 [ xsize ])
        (reg:SI 241)))
$1 = void
(gdb) p debug_rtx(insn)
(insn 741 739 678 81 (set (reg/v:SI 173 [ xsize ])
        (if_then_else:SI (ge (reg:CCGC 17 flags)
                (const_int 0 [0]))
            (reg/v:SI 173 [ xsize ])
            (reg:SI 241))) ../../trunk/gcc/alias.c:1940 893 {*movsicc_noc}
     (expr_list:REG_EQUAL (if_then_else:SI (ge (reg:CCGC 17 flags)
                (const_int 0 [0]))
            (reg/v:SI 173 [ xsize ])
            (const_int -1 [0xffffffffffffffff]))
        (nil)))
$2 = void
(gdb)



More information about the Gcc-patches mailing list