public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/96373] SVE miscompilation on vectorized division loop, leading to FP exception
Date: Fri, 27 Jan 2023 17:04:10 +0000	[thread overview]
Message-ID: <bug-96373-4-77Y5MMY2WW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96373-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

https://gcc.gnu.org/g:7486fe153adaa868f36248b72f3e78d18b1b3ba1

commit r13-5458-g7486fe153adaa868f36248b72f3e78d18b1b3ba1
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Jan 27 17:03:51 2023 +0000

    Add support for conditional xorsign [PR96373]

    This patch is an optimisation, but it's also a prerequisite for
    fixing PR96373 without regressing vect-xorsign_exec.c.

    Currently the vectoriser vectorises:

      for (i = 0; i < N; i++)
        r[i] = a[i] * __builtin_copysignf (1.0f, b[i]);

    as two unconditional operations (copysign and mult).
    tree-ssa-math-opts.cc later combines them into an "xorsign" function.
    This works for both Advanced SIMD and SVE.

    However, with the fix for PR96373, the vectoriser will instead
    generate a conditional multiplication (IFN_COND_MUL).  Something then
    needs to fold copysign & IFN_COND_MUL to the equivalent of a conditional
    xorsign.  Three obvious options were:

    (1) Extend tree-ssa-math-opts.cc.
    (2) Do the fold in match.pd.
    (3) Leave it to rtl combine.

    I'm against (3), because this isn't a target-specific optimisation.
    (1) would be possible, but would involve open-coding a lot of what
    match.pd does for us.  And, in contrast to doing the current
    tree-ssa-math-opts.cc optimisation in match.pd, there should be
    no danger of (2) happening too early.  If we have an IFN_COND_MUL
    then we're already past the stage of simplifying the original
    source code.

    There was also a choice between adding a conditional xorsign ifn
    and simply open-coding the xorsign.  The latter seems simpler,
    and means less boiler-plate for target-specific code.

    The signed_or_unsigned_type_for change is needed to make sure
    that we stay in "SVE space" when doing the optimisation on 128-bit
    fixed-length SVE.

    gcc/
            PR tree-optimization/96373
            * tree.h (sign_mask_for): Declare.
            * tree.cc (sign_mask_for): New function.
            (signed_or_unsigned_type_for): For vector types, try to use the
            related_int_vector_mode.
            * genmatch.cc (commutative_op): Handle conditional internal
functions.
            * match.pd: Fold an IFN_COND_MUL+copysign into an IFN_COND_XOR+and.

    gcc/testsuite/
            PR tree-optimization/96373
            * gcc.target/aarch64/sve/cond_xorsign_1.c: New test.
            * gcc.target/aarch64/sve/cond_xorsign_2.c: Likewise.

  parent reply	other threads:[~2023-01-27 17:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 15:27 [Bug target/96373] New: " matz at gcc dot gnu.org
2020-08-04 13:41 ` [Bug target/96373] " rsandifo at gcc dot gnu.org
2020-08-04 13:49 ` rguenth at gcc dot gnu.org
2020-08-04 14:38 ` matz at gcc dot gnu.org
2020-08-04 14:59 ` rsandifo at gcc dot gnu.org
2020-08-04 15:46 ` schwab@linux-m68k.org
2020-08-05 10:08 ` rsandifo at gcc dot gnu.org
2020-08-05 10:15 ` rguenther at suse dot de
2020-08-05 10:28 ` rsandifo at gcc dot gnu.org
2020-08-05 11:09 ` rguenther at suse dot de
2020-08-05 12:24 ` matz at gcc dot gnu.org
2020-08-05 13:02 ` matz at gcc dot gnu.org
2023-01-11 23:50 ` pinskia at gcc dot gnu.org
2023-01-11 23:54 ` pinskia at gcc dot gnu.org
2023-01-27 17:04 ` cvs-commit at gcc dot gnu.org [this message]
2023-02-14  2:05 ` cvs-commit at gcc dot gnu.org
2023-02-14  9:18 ` cvs-commit at gcc dot gnu.org
2023-02-27  2:50 ` cvs-commit at gcc dot gnu.org
2023-02-27  2:57 ` cvs-commit at gcc dot gnu.org
2023-04-03  8:58 ` cvs-commit at gcc dot gnu.org
2023-04-14  8:19 ` [Bug target/96373] [10/11 Regression] " rguenth at gcc dot gnu.org
2023-05-29 10:03 ` jakub at gcc dot gnu.org
2024-02-29  5:33 ` [Bug target/96373] [11 " 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-96373-4-77Y5MMY2WW@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).