On Thu, Nov 27, 2014 at 6:48 AM, Richard Biener <rguent...@suse.de> wrote:
>
> Currently the order in which patterns in match.pd match is pretty
> random (well, it's deterministic of course).  This is bad if there
> are multiple possible matches such as in
>
>   z = x + 1;
>   w = z + 0;
>
> where we have both z + 0 -> z and (x + 1) + 0 -> x + (1 + 0).
> Currently the latter happens to be applied and thus we simplify to
>
>   z = x + 1;
>   w = x + 1;
>
> which is bad for propagation engines which only handle constant
> or SSA name results (and also either generates redundant code or leaves
> dead code).
>
> Thus the following patch makes sure that if there are multiple
> matches possible then the pattern first appearing in match.pd
> is chosen.
>
> This slightly increases the number of instructions executed during
> the matching in the worst case but is certainly the best course
> of action here (other possibilities are to make the patterns
> disjunct by disabling the latter for the + 0 case).  At least
> it matches how other generated matchers behave.
>
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
>
> Richard.
>
> 2014-11-27  Richard Biener  <rguent...@suse.de>
>
>         PR middle-end/64084
>         * genmatch.c (dt_node::gen_kids_1): New function, split out
>         from dt_node::gen_kids.
>         (decision_tree::cmp_node): DT_TRUE are generally not equal.
>         (decision_tree::find_node): Treat DT_TRUE as barrier for
>         node CSE on the same level.
>         (dt_node::append_node): Do not keep DT_TRUE last.
>         (dt_node::gen_kids): Emit code after each DT_TRUE node seen.

This caused:

FAIL: gcc.dg/pr37289.c scan-tree-dump original "-\\(long unsigned int\\) x"

on x86.

-- 
H.J.

Reply via email to