[PATCH] Implement constant-folding simplifications of reductions.

2022-02-20 Thread Roger Sayle
This patch addresses a code quality regression in GCC 12 by implementing some constant folding/simplification transformations for REDUC_PLUS_EXPR in match.pd. The motivating example is gcc.dg/vect/pr89440.c which with -O2 -ffast-math (with vectorization now enabled) gets optimized to: float f (f

Re: [PATCH] Implement constant-folding simplifications of reductions.

2022-02-21 Thread Marc Glisse
On Mon, 21 Feb 2022, Roger Sayle wrote: +/* Fold REDUC (@0 op VECTOR_CST) as REDUC (@0) op REDUC (VECTOR_CST). */ +(for reduc (IFN_REDUC_PLUS IFN_REDUC_MAX IFN_REDUC_MIN IFN_REDUC_FMAX +IFN_REDUC_FMIN IFN_REDUC_AND IFN_REDUC_IOR IFN_REDUC_XOR) + op (plus max min IFN_FMAX IFN_FMI

RE: [PATCH] Implement constant-folding simplifications of reductions.

2022-02-21 Thread Roger Sayle
e > Cc: gcc-patches@gcc.gnu.org > Subject: Re: [PATCH] Implement constant-folding simplifications of reductions. > > On Mon, 21 Feb 2022, Roger Sayle wrote: > > > +/* Fold REDUC (@0 op VECTOR_CST) as REDUC (@0) op REDUC > (VECTOR_CST). > > +*/ (for redu

Re: [PATCH] Implement constant-folding simplifications of reductions.

2022-02-21 Thread Richard Biener via Gcc-patches
_1 from sNaN to qNaN and thus relies on -fno-signalling-nans? Otherwise OK. Thanks, Richard. > Cheers, > Roger > -- > > > -Original Message- > > From: Marc Glisse > > Sent: 21 February 2022 08:21 > > To: Roger Sayle > > Cc: gcc-patches@gcc.gnu.org &g

Re: [PATCH] Implement constant-folding simplifications of reductions.

2022-02-21 Thread Jeff Law via Gcc-patches
On 2/21/2022 3:55 AM, Richard Biener via Gcc-patches wrote: On Mon, Feb 21, 2022 at 9:31 AM Roger Sayle wrote: Hi Marc, I'm assuming that the use (semantics) of a REDUC_PLUS expr allow the reduction to be done in any order, for example the testcase requires -ffast-math to allow the REDUC_PL