This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Using associativity for optimization
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: shmeel gutl <shmeelgutl at shmuelhome dot mine dot nu>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Tue, 2 Dec 2014 11:23:50 +0100
- Subject: Re: Using associativity for optimization
- Authentication-results: sourceware.org; auth=none
- References: <547CF5BE dot 7050901 at shmuelhome dot mine dot nu>
On Tue, Dec 2, 2014 at 12:11 AM, shmeel gutl
<shmeelgutl@shmuelhome.mine.nu> wrote:
> While testing my implementation of passing arguments in registers, I noticed
> that gcc 4.7 creates instruction dependencies when it doesn't have to.
> Consider:
>
> int foo(int a1, int a2, int a3, int a4)
> {
> return a1|a2|a3|a4;
> }
>
> gcc, even with -O2 generated code that was equivalent to
>
> temp1 = a1 | a2;
> temp2 = temp1 | a3;
> temp3 = temp2 | a4;
>
> return temp3;
>
> This code must be executed serially.
>
> Could I create patterns, or enable optimizations that would cause the
> compiler to generate
>
> temp1 = a1 | a2;
> temp2 = a3 | a4;
> temp3 = temp1 | temp2;
>
> Thereby allowing the scheduler to compute temp1 and temp2 in parallel.
You can tune it with --param tree-reassoc-width=N, not sure if that
was implemented for 4.7 already.
Richard.