This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix PR44483: incrementally gimplify BB predicates to avoid redundant computations.
- From: Ira Rosen <IRAR at il dot ibm dot com>
- To: Sebastian Pop <sebpop at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Guenther <rguenther at suse dot de>
- Date: Tue, 29 Jun 2010 11:07:15 +0300
- Subject: Re: [patch] Fix PR44483: incrementally gimplify BB predicates to avoid redundant computations.
- References: <AANLkTinGpk3FyNKkdiLn7hh2Ovp3_JuzRVevvOGm_L5h@mail.gmail.com>
Hi,
gcc-patches-owner@gcc.gnu.org wrote on 11/06/2010 01:52:58 AM:
>
> Hi,
>
> The attached patch fixes PR44483 by early gimplifying the expressions
> that are used in the predicates of basic blocks: in the testcase,
> these expressions are redundant and if not gimplified in time, they
> end up to form an exponential tree of conditions.
>
> With this patch we gimplify the predicates, and collect the gimple
> sequences during the analysis phase. Because we now force the
> predicate of a BB to be an SSA_NAME, this is what is used further on
> for the next basic block, avoiding the full expression to be
> recomputed. When the if-conversion analysis fails, the SSA_NAMEs used
> in the gimple sequences are released using free_stmt_operands.
> Otherwise the gimple sequences are inserted in the end of each basic
> block that is predicated by these computations. These computations
> are then used in the if-conversion of the PHI nodes following the BB.
With this patch if-conversion generates for
for (i = 0; i < N; i++)
if (arr[i] < limit)
{
pos = i + 1;
limit = arr[i];
}
some redundant statements, that were not created before the patch (none of
them are used outside the loop):
# pos_22 = PHI <pos_1(4), 1(2)>
# i_23 = PHI <prephitmp.8_2(4), 0(2)>
# limit_24 = PHI <limit_4(4), 1.28e+2(2)>
# ivtmp.9_18 = PHI <ivtmp.9_17(4), 64(2)>
limit_9 = arr[i_23];
pos_10 = i_23 + 1;
D.4534_12 = limit_9 < limit_24; <-----
pretmp.7_3 = i_23 + 1;
D.4535_20 = limit_9 >= limit_24; <-----
pos_1 = [cond_expr] limit_9 >= limit_24 ? pos_22 : pos_10;
limit_4 = [cond_expr] limit_9 >= limit_24 ? limit_24 : limit_9;
prephitmp.8_2 = [cond_expr] limit_9 >= limit_24 ? pretmp.7_3 : pos_10;
ivtmp.9_17 = ivtmp.9_18 - 1;
D.4536_19 = D.4534_12 || D.4535_20; <-----
if (ivtmp.9_17 != 0)
goto <bb 4>;
else
goto <bb 5>;
The statements are removed by later dce pass, but they interfere with my
attempts to vectorize this loop.
Is it possible to get rid of them in if-conversion? Should I open a PR?
Thanks,
Ira
>
> The patch passed make -k check RUNTESTFLAGS=tree-ssa.exp and vect.exp
> and is right now under regstrap on amd64-linux. Ok for trunk after
regstrap?
>
> Thanks,
> Sebastian Pop
> --
> AMD / Open Source Compiler Engineering / GNU Tools
> [attachment "0001-Fix-PR44483-incrementally-gimplify-BB-predicates-
> to-.patch" deleted by Ira Rosen/Haifa/IBM]