http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59303

--- Comment #10 from davidxl at google dot com ---
My patch does this.
1) it first does aggressive simplification iteratively (more rules can be added
later). 
2) it then does normalization by building up larger predicate trees by
following ud chain and bitwise or/and operations. It handles simple PHIs
including also degenerated phis.

The new dump reports:

in foo,

predicate for def:

m_7(D) > 100
(.OR.)
n_5(D) <= 9
(.OR.)
l_12(D) != 0
(.OR.)
r_10(D) <= 19

use1:

m_7(D) > 100
(.OR.)
n_5(D) <= 9
(.OR.)
r_10(D) <= 9

use2:

m_7(D) > 100
(.OR.)
n_5(D) <= 9
(.OR.)
r_10(D) <= 19


For foo2, the predicates are properly built, but the patch has a bug in
predicate set inclusion testing leading to a false negative.

David

(In reply to Jakub Jelinek from comment #9)
> Created attachment 31496 [details]
> cleanups
> 
> I had also a brief look at this recently, but haven't made progress beyond
> attached formatting/cleanup patch so far (plus only dumping details with
> *-details, otherwise the dumps are pretty much inconsistent).
> My conclusion has also been that to fix this up the predicates would need to
> be normalized before comparison, and simplified, at least if the initial
> subset check fails.  On uninit-pred-8_b.c there has been additional
> complication because PRE decides to change the IL and we end up with:
>   <bb 3>:
>   pretmp_24 = r_10(D) <= 19;
>   goto <bb 5>;
> 
>   <bb 4>:
>   _11 = r_10(D) <= 19;
>   _13 = l_12(D) != 0;
>   _14 = _11 | _13;
>   if (_14 != 0)
>     goto <bb 14>;
>   else
>     goto <bb 15>;
> 
>   <bb 14>:
>   goto <bb 3>;
>   
>   <bb 15>:
> 
>   <bb 5>:
>   # v_1 = PHI <v_15(D)(15), r_10(D)(3)>
>   # prephitmp_30 = PHI <0(15), pretmp_24(3)>
>   if (m_7(D) != 0)
>     goto <bb 6>;
>   else
>     goto <bb 7>;
> 
>   <bb 6>:
>   g.0_17 = g;
>   g.1_18 = g.0_17 + 1;
>   g = g.1_18;
>   goto <bb 8>;
>   
>   <bb 7>:
>   bar ();
> 
>   <bb 8>:
>   _3 = prephitmp_30 | _9;
>   if (_3 != 0)
> so the prephitmp_30 would need to be canonicalized into _14 != 0 && r_10(D)
> <= 19 aka (r_10(D) <= 19 || l_12(D) != 0) && r_10(D) <= 19 and from there to
> r_10(D) <= 19.

Reply via email to