https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68894

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just a quick note on this part of the bug report:

(In reply to Richard Biener from comment #3)
> Doing this in a classical way in phi-opt might end up being slightly
> convoluted.
> So I'd propose to try to utilize match-and-simplify by adding
> 
> 
> (cond (ge @0 @1) (max:s @0 @2) (max:s @1 @2))
> -> (max (max @0 @1) @2)

I am going to submit patches for the above later today or tomorrow.

> 
> kind patterns and from phiopt doing exploded queries of this simplification
> by seeding the cond expr from the dominating condition plus the PHI operands.
> 
>  res = gimple_simplify (COND_EXPR, build2 /* Ick */ (cond-code,
> boolean_type, cond-op0, cond-op1), true-phi-arg, false-phi-arg, &seq,
> follow_single_use_edges);
> 
> of course you need more than a single pattern or consider swapped ops 2 and 3
> (not yet supported).  In the end explicit pattern explosion might make a
> manual
> implementation in phiopt easier (who knows).

This part is fully implemented in r14-204-gf1f5cbaa3f716fcb472dee5 (there was a
few pieces of the match-and-simplify phiopt implemented in GCC 12). 

Note phiopt already does "a ? b : c" -> "!a ? c : b" (where !a folds)
(implemented in r12-2040-ga50cecb20a10) specifically because of the explosion
issue.

Reply via email to