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

--- Comment #11 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #9)
> Another related issue is this example function:
> 
> unsigned char h (unsigned char a, int b)
> {
>   return (unsigned char)(a + b);
> }
> 
> It seems that the fwprop1 pass causes this.

I've tried disabling fwprop and matching of combined insns with hard regs in
sh_legitimate_combined_insn.  But it doesn't help in this case.  The problem is
that

(insn 8 7 13 2 (set (reg:SI 169)
        (plus:SI (reg/v:SI 165 [ a ])
                  ^^^^^^^^
            (subreg:SI (reg:QI 168 [ b ]) 0))) sh_tmp.cpp:14 63
{*addsi3_compact}

the reg:SI 165 is zero_extended beforehand and then of course also the
subreg:SI (reg:QI 168) doesn't help it anymore.
If -mrenesas is not specified the example compiles to

        mov     r5,r0
        add     r4,r0
        rts
        extu.b  r0,r0   // zero extension of return value mandated by gnu abi

which doesn't have the problem.  It's initially expanded with two zero_extend
(one on the function arg + one for the return value) and then combine figures
that the first zero_extend can be eliminated.

Reply via email to