public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/106902] [11/12/13/14 Regression] Program compiled with -O3 -mfma produces different result
Date: Thu, 18 May 2023 05:53:58 +0000	[thread overview]
Message-ID: <bug-106902-4-kkQ15OXBWx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106902-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #24 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #23)
> (In reply to Alexander Monakov from comment #22)
> > Created attachment 55105 [details]
> > patch 1/3
> > 
> > (In reply to Richard Biener from comment #21)
> > > 
> > > Sounds reasonable.  Though I wouldn't use GENERIC folding but instead
> > > some folding-like code in c-family/ that for example would get invoked
> > > by genericization or via the gimplification hook?  If we'd add GENERIC
> > > folding in fold-const.cc or match.pd the chance is that it will pick up
> > > FMAs "late".
> > 
> > Agreed, thank you. I'm working on it. The attached patch implements this via
> > c_gimplify_expr and passes bootstrap+regtest under 'configure
> > --with-cpu=znver2' (i.e. with fma available by default).
> 
> Hmm, seems like this should not be in the C family but the generic part of
> gimplifier. Because IIRC Fortran has similar rules but IIRC fortran
> front-end emits PAREN_EXPR a lot more which improves the situtation there ...

The actual worker can be put into generic code but frontends need to set
the rules here I think as they might differ slightly.

As of the patch it looks good, I wonder if we want to check for OPTIMIZE_BOTH
though since at least when no extra negations are required the contraction
should also be a win when optimizing for size?

Also I wondered about the PROP_gimple_any check - do we get into the
gimplification langhook after lowering?  I see we are not resetting the
langhook after lowering (only in free-lang-data, but that only runs with LTO).
We probably at least should gate the langhook invocation in the gimplifier
with what you added in the patch or specify whether the gimplifier is
invoked from the middle-end via the gimplifier context.

If we go for c-family only the genericize entry could be another place to
handle this.

Did you run into any of NON_LVALUE / C_MAYBE_CONST wrappings of the
multiplication btw?

  parent reply	other threads:[~2023-05-18  5:53 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-10 18:58 [Bug tree-optimization/106902] New: Program compiled with -O3 -fmfa " jhllawrence963 at gmail dot com
2022-09-10 19:07 ` [Bug target/106902] Program compiled with -O3 -mfma " pinskia at gcc dot gnu.org
2022-09-12  8:01 ` [Bug target/106902] [11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-09-12 14:08 ` marxin at gcc dot gnu.org
2022-09-12 14:10 ` [Bug target/106902] [11/12 " marxin at gcc dot gnu.org
2022-09-13  7:06 ` [Bug target/106902] [11/12/13 " rguenth at gcc dot gnu.org
2022-09-14 15:20 ` amonakov at gcc dot gnu.org
2022-09-15  9:33 ` amonakov at gcc dot gnu.org
2022-09-17 18:19 ` jhllawrence963 at gmail dot com
2022-09-17 18:23 ` jhllawrence963 at gmail dot com
2022-09-19  7:08 ` rguenth at gcc dot gnu.org
2022-09-19  7:14 ` amonakov at gcc dot gnu.org
2022-09-19  7:25 ` rguenth at gcc dot gnu.org
2022-09-19  8:14 ` amonakov at gcc dot gnu.org
2022-09-19  9:44 ` rguenth at gcc dot gnu.org
2022-09-27 18:31 ` amonakov at gcc dot gnu.org
2022-09-29  6:41 ` rguenth at gcc dot gnu.org
2022-09-29 11:28 ` amonakov at gcc dot gnu.org
2022-09-29 13:39 ` rguenther at suse dot de
2022-09-30  6:17 ` amonakov at gcc dot gnu.org
2023-05-11 17:32 ` [Bug target/106902] [11/12/13/14 " amonakov at gcc dot gnu.org
2023-05-12  6:27 ` rguenth at gcc dot gnu.org
2023-05-17 18:49 ` amonakov at gcc dot gnu.org
2023-05-17 18:54 ` pinskia at gcc dot gnu.org
2023-05-18  5:53 ` rguenth at gcc dot gnu.org [this message]
2023-05-18  8:31 ` amonakov at gcc dot gnu.org
2023-05-18 16:03 ` amonakov at gcc dot gnu.org
2023-05-18 16:52 ` rguenther at suse dot de
2023-05-29 10:07 ` jakub at gcc dot gnu.org

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=bug-106902-4-kkQ15OXBWx@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).