public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] match.pd: Fix up sqrt (sqrt (x)) simplification [PR109301]
Date: Tue, 28 Mar 2023 09:23:23 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2303280920380.18795@jbgna.fhfr.qr> (raw)
In-Reply-To: <ZCKwTE8cpXMrHLVN@tucnak>

On Tue, 28 Mar 2023, Jakub Jelinek wrote:

> On Tue, Mar 28, 2023 at 08:57:12AM +0000, Richard Biener wrote:
> > Hmm, but canonicalize_math_p () should be false after vectorization?
> > 
> > When we moved the pass we should have made sure to put the
> > PROP_gimple_opt_math property set to pass_expand_powcabs instead.
> 
> Which pass is the one that actually canonicalizes the math such
> that we want to keep its choices for later?
> I must say I don't know the details why the sincos path has been
> even moved.

The pass was split into sincos + pass_expand_powcabs - canonicalization
happens through folding and pass_expand_powcabs expands
pow (x, 2) to x * x.  Folding would make x * x to pow (x, 2)
so it's important to set the property after pass_expand_powcabs.

I think we moved sincos because vectorizing cexpi never materialized(?)
but maybe I misremember.

> > Now, the sqrt (sqrt ()) canonicalization to pow (.., 1./4) is
> > probably invalid anyway, not sure if we can add a user-written
> > vector sqrt testcase that would trigger during the canonicalization
> 
> How do we write user written vector sqrt?

I'm not sure ;)

> > phase.  There are other uses of build_real that have the same
> > issue - what's your conclusion this is never a problem there?
> 
> Looking through build_real* calls in match.pd, others are
> either on simplifications of some expressions with REAL_CST operand
> (so can't be vector then), or using
> LOG*/EXP*/CBRT*/SIN*/ATAN*/COS*/POW*/CABS*/HYPOT*/POWI*/SIGNBIT*
> calls in the expression being simplified, or this case.
> I think no target provides vector optabs for those or they don't
> have internal fns at all.
> Maybe
> (simplify
>  /* signbit(x) -> x<0 if x doesn't have signed zeros.  */
>  (SIGNBIT @0)
>  (if (!HONOR_SIGNED_ZEROS (@0))
>   (convert (lt @0 { build_real (TREE_TYPE (@0), dconst0); }))))
> ?

Maybe.

But as said, the fix is probably to move the pass property.

Richard.

  reply	other threads:[~2023-03-28  9:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28  8:25 Jakub Jelinek
2023-03-28  8:57 ` Richard Biener
2023-03-28  9:15   ` Jakub Jelinek
2023-03-28  9:23     ` Richard Biener [this message]
2023-03-28 10:07       ` [PATCH] tree-ssa-math-opts: Move PROP_gimple_opt_math from sincos pass to powcabs [PR109301] Jakub Jelinek
2023-03-28 10:53         ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nycvar.YFH.7.77.849.2303280920380.18795@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).