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 tree-optimization/95060] vfnmsub132ps is not generated with -ffast-math
Date: Tue, 12 May 2020 06:56:14 +0000	[thread overview]
Message-ID: <bug-95060-4-zmhQQe6QIF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95060-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |11.0
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-05-12
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
             Target|                            |x86_64-*-* i?86-*-*

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
FMA generation already folds the FMA stmt:

      if (cond)
        fma_stmt = gimple_build_call_internal (IFN_COND_FMA, 5, cond, mulop1,
                                               op2, addop, else_value);
      else
        fma_stmt = gimple_build_call_internal (IFN_FMA, 3, mulop1, op2, addop);
      gimple_set_lhs (fma_stmt, gimple_get_lhs (use_stmt));
      gimple_call_set_nothrow (fma_stmt, !stmt_can_throw_internal (cfun,
                                                                   use_stmt));
      gsi_replace (&gsi, fma_stmt, true);
      /* Follow all SSA edges so that we generate FMS, FNMA and FNMS
         regardless of where the negation occurs.  */
      gimple *orig_stmt = gsi_stmt (gsi);
      if (fold_stmt (&gsi, follow_all_ssa_edges))
        {
          if (maybe_clean_or_replace_eh_stmt (orig_stmt, gsi_stmt (gsi)))
            gcc_unreachable ();
          update_stmt (gsi_stmt (gsi));

but not the negate it feeds since with -ffast-math we have
-((a[i] * b[i]) + c[i]) as canonical form it seems (reassoc does this).

float r[8], a[8], b[8], c[8];

void
test_fnms (void)
{
  for (int i = 0; i < 8; i++)
    r[i] = -((a[i] * b[i]) + c[i]);
}

would be an alternative testcase, not handled without -ffast-math either.

I'd suggest to fold the single-use stmt of the fma_stmts lhs if any
[and if it is a negate].

  parent reply	other threads:[~2020-05-12  6:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 15:07 [Bug tree-optimization/95060] New: " ubizjak at gmail dot com
2020-05-11 15:12 ` [Bug tree-optimization/95060] " ubizjak at gmail dot com
2020-05-11 19:49 ` jakub at gcc dot gnu.org
2020-05-12  6:56 ` rguenth at gcc dot gnu.org [this message]
2020-05-12 10:21 ` jakub at gcc dot gnu.org
2020-05-13  9:21 ` cvs-commit at gcc dot gnu.org
2020-05-13  9:23 ` jakub at gcc dot gnu.org
2021-08-10 23:13 ` pinskia 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-95060-4-zmhQQe6QIF@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).