On Thu, May 7, 2026 at 9:34 AM Pengxuan Zheng
<[email protected]> wrote:
>
> The original patch adding the "min|max(a+|-c,b+|-c) -> min|max(a,b)+|-c" 
> pattern
> missed integral type checks and caused some powerpc tests to fail.
>
>         PR tree-optimization/125214
>
> gcc/ChangeLog:
>
>         * match.pd (min|max(a+|-c,b+|-c)): Add integral type check.

Ok but please add a testcase like the one I added to the bug report.

Thanks,
Andrea


>
> Signed-off-by: Pengxuan Zheng <[email protected]>
> ---
>  gcc/match.pd | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 1a7d820779f..04faffb760d 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -5010,7 +5010,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>  (for minmax (min max)
>   (simplify
>    (minmax:c (plus:cs @0 @2) (plus:s @1 @2))
> -   (if (TYPE_OVERFLOW_UNDEFINED (type)
> +   (if (INTEGRAL_TYPE_P (type)
> +       && TYPE_OVERFLOW_UNDEFINED (type)
>         && !TYPE_OVERFLOW_SANITIZED (type))
>      (plus (minmax @0 @1) @2))))
>
> @@ -5018,7 +5019,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>  (for minmax (min max)
>   (simplify
>    (minmax:c (minus:s @0 @2) (minus:s @1 @2))
> -   (if (TYPE_OVERFLOW_UNDEFINED (type)
> +   (if (INTEGRAL_TYPE_P (type)
> +       && TYPE_OVERFLOW_UNDEFINED (type)
>         && !TYPE_OVERFLOW_SANITIZED (type))
>      (minus (minmax @0 @1) @2))))
>
> --
> 2.34.1
>

Reply via email to