public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114603] New: aarch64: Invalid SVE cnot optimisation
@ 2024-04-05 12:29 rsandifo at gcc dot gnu.org
  2024-04-05 13:47 ` [Bug target/114603] " cvs-commit at gcc dot gnu.org
  2024-04-05 15:45 ` rsandifo at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-04-05 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114603
           Summary: aarch64: Invalid SVE cnot optimisation
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rsandifo at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*-*-*

An overly lax condition on the cnot combine pattern means that we optimise:

#include <arm_sve.h>

svint32_t foo(svbool_t pg, svint32_t y)
{
  return svsel(svcmpeq(pg, y, 0), svdup_s32(1), svdup_s32(0));
}

to a single cnot:

foo:
        cnot    z0.s, p0/m, z0.s
        ret

The result must be 0 for inactive elements of pg, whereas the above would leave
the elements unchanged instead.

This seems to have been around since the SVE ACLE was first added.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/114603] aarch64: Invalid SVE cnot optimisation
  2024-04-05 12:29 [Bug target/114603] New: aarch64: Invalid SVE cnot optimisation rsandifo at gcc dot gnu.org
@ 2024-04-05 13:47 ` cvs-commit at gcc dot gnu.org
  2024-04-05 15:45 ` rsandifo at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-05 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from GCC 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:67cbb1c638d6ab3a9cb77e674541e2b291fb67df

commit r14-9811-g67cbb1c638d6ab3a9cb77e674541e2b291fb67df
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Apr 5 14:47:15 2024 +0100

    aarch64: Fix bogus cnot optimisation [PR114603]

    aarch64-sve.md had a pattern that combined:

            cmpeq   pb.T, pa/z, zc.T, #0
            mov     zd.T, pb/z, #1

    into:

            cnot    zd.T, pa/m, zc.T

    But this is only valid if pa.T is a ptrue.  In other cases, the
    original would set inactive elements of zd.T to 0, whereas the
    combined form would copy elements from zc.T.

    gcc/
            PR target/114603
            * config/aarch64/aarch64-sve.md (@aarch64_pred_cnot<mode>): Replace
            with...
            (@aarch64_ptrue_cnot<mode>): ...this, requiring operand 1 to be
            a ptrue.
            (*cnot<mode>): Require operand 1 to be a ptrue.
            * config/aarch64/aarch64-sve-builtins-base.cc
(svcnot_impl::expand):
            Use aarch64_ptrue_cnot<mode> for _x operations that are predicated
            with a ptrue.  Represent other _x operations as fully-defined _m
            operations.

    gcc/testsuite/
            PR target/114603
            * gcc.target/aarch64/sve/acle/general/cnot_1.c: New test.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/114603] aarch64: Invalid SVE cnot optimisation
  2024-04-05 12:29 [Bug target/114603] New: aarch64: Invalid SVE cnot optimisation rsandifo at gcc dot gnu.org
  2024-04-05 13:47 ` [Bug target/114603] " cvs-commit at gcc dot gnu.org
@ 2024-04-05 15:45 ` rsandifo at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-04-05 15:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-05
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rsandifo at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Fix on trunk so far, but I'll backport if possible.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-05 15:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-05 12:29 [Bug target/114603] New: aarch64: Invalid SVE cnot optimisation rsandifo at gcc dot gnu.org
2024-04-05 13:47 ` [Bug target/114603] " cvs-commit at gcc dot gnu.org
2024-04-05 15:45 ` rsandifo at gcc dot gnu.org

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).