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

Sébastien Michelland <sebastien.michell...@ens-lyon.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[SH] miscompilation of loop |[SH] miscompilation due to
                   |involving noreturn call     |incorrect elimination of
                   |                            |comparisons to 0

--- Comment #4 from Sébastien Michelland <sebastien.michell...@ens-lyon.fr> ---
> Then this is a target specific issue until provided otherwise. mach stands 
> for machine (target) specific pass.

That makes a lot of sense, thanks.

I found a much simpler example exhibiting the bug:

int f(int i, int j)
{
    if(i < 0) return 1;
    if(i + j) return 3;
    return i;
}

Latest HEAD with -O1 (same setup as before) compiles it to

_f:     cmp/pz  r4
        bf      .L3
        bf      .L4
        rts     
        mov     r4,r0
.L3:    rts     
        mov     #1,r0
.L4:    rts     
        mov     #3,r0

incorrectly eliminating the test for (i + j) != 0. The label .L4 returning 3 is
evidently unreachable.

Comparing to 0 seems to be required. My previous example also compiles
correctly if we check values[i] != 1 instead, which invalidates the loop/CFG
theory.

Few commits changed the SH subtree since GCC 11.1.0; I should be able to bisect
it. In the meantime I've updated the title.

Reply via email to