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

--- Comment #6 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
Created attachment 36040
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36040&action=edit
.i file for gengtype.c

I've confirmed a miscompile for gengtype.c with -O1 on my 5/6
compilers.  With them,

     if (union_p)
       {
         oprintf (d->of, "%*sbreak;\n", d->indent, "");
         d->indent -= 2;
       }

lines in gengtype.c:walk_type function are compiled like as:

        bf      .L2253
        mov.l   .L2593,r7
        mov.l   @(36,r12),r6
        mov.l   .L2580,r5
        mov.l   .L2595,r1
        jsr     @r1
        ...

i.e. the instruction testing union_p variable is removed.
The resulted gengtype produces files without "break" in many
cases.  Although it's the other way around with the reported
full of "break" symptom, I think the both are the same issue.
The deletion has happened in sh_split_movrt_negc_to_movt_xor
which is called by movrt_negc insn_and_split.  It seems that
that splitting is applied for the case

        tst     reg,reg
        mov     #-1,reg1
        negc    reg1,reg1
        ...
        call ...
        ...
        tst     reg,reg

and the last tst was removed.  Oleg, could you take a look into
this?

BTW, I guess that

> * Build with -O1 on sh4 (try to work around PR target/66358).

will open a can of worms :-)

Reply via email to