https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68894
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #7)
> Mine, working on improving phi-opt here; though the hoisting of the load is
> something which needs to be looked into further.
>
> I have the match.pd pattern for what is mentioned in comment #3:
> /* These was part of minmax phiopt. */
> /* Optimize (a CMP b) ? minmax<a, c> : minmax<b, c>
> to minmax<min/max<a, b>, c> */
> (for minmax (min max)
> (for cmp (lt le gt ge)
> (simplify
> (cond (cmp @1 @3) (minmax:c @1 @4) (minmax:c @2 @4))
> (with
> {
> tree_code code = minmax_from_comparison (cmp, @1, @2, @1, @3);
> }
> (if (code == MIN_EXPR)
> (minmax (min @1 @2) @4)
> (if (code == MAX_EXPR)
> (minmax (max @1 @2) @4)))))))
>
> I also have the improvements to match_simplify_replacement which are needed
> to use those patterns too. I will be submitting them for GCC 14.
Note these patterns are enough for the ifcvt pass for the vectorizer to
generate:
pretmp_24 = a3D.2740[i_20];
_35 = MIN_EXPR <_1, _2>;
d_9 = MIN_EXPR <pretmp_24, _35>;
Rather than the current:
d_14 = MIN_EXPR <_1, pretmp_24>;
_23 = _1 < _2;
d_13 = MIN_EXPR <_2, pretmp_24>;
d_9 = _23 ? d_14 : d_13;