Re: Non-optimal code generated for H8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 29, 2019 at 02:19:25PM -0600, Jeff Law wrote:
> On 10/29/19 2:03 PM, Mikael Tillenius wrote:
> > I am using a cross compiler for Renesas H8S. In a few places it
> > generates really bad code. Given the following program:
> > 
> > struct s {
> >     char a, b;
> >     char c[11];
> > } x[2];
> > 
> > void test(int n)
> > {
> >     struct s *sp = &x[n];
> > 
> >     sp->a = 1;
> >     sp->b = 1;
> > }

> As we leave gimple the code looks like:
> 
>   MEM <struct s[2]> [(struct s *)&x][n_1(D)].a = 1;
>   MEM <struct s[2]> [(struct s *)&x][n_1(D)].b = 1;
> 
> One might argue that DOM or FRE should have created a common
> subexpression for the address arithmetic here.  Even so it's not bad.
> 
> CSE doesn't do its job though.  THere's clearly a REG_EQUAL note which
> should have allowed it to at least cleanup the redundant multiplication
> for the address calculation.

And on other targets it does do its job fine, say riscv32, or m68k -O1
(the -O1 to prevent the two stores from being optimised into one).

I haven't managed to find another target where multiplication by 13 is
done with a libcall though.  Maybe I should look harder.

> I recommend filing a bug report.

+1


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux