public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Haochen Jiang <haochen.jiang@intel.com>
Cc: gcc-patches@gcc.gnu.org, hongtao.liu@intel.com
Subject: Re: [PATCH] Support Intel CMPccXADD
Date: Mon, 24 Oct 2022 11:44:57 +0200	[thread overview]
Message-ID: <CAFULd4YraK=YDLxSZFfSNKkRqA9Ttt_E_a94Cq7UxeU0TijqbA@mail.gmail.com> (raw)
In-Reply-To: <20221024090125.16371-1-haochen.jiang@intel.com>

On Mon, Oct 24, 2022 at 11:01 AM Haochen Jiang <haochen.jiang@intel.com> wrote:
>
> Hi all,
>
> I just refined CMPccXADD patch to make the enum in order intrin file
> aligned with how opcode does.
>
> Ok for trunk?
>
> BRs,
> Haochen
>
> gcc/ChangeLog:
>
>         * common/config/i386/cpuinfo.h (get_available_features):
>         Detect cmpccxadd.
>         * common/config/i386/i386-common.cc
>         (OPTION_MASK_ISA2_CMPCCXADD_SET,
>         OPTION_MASK_ISA2_CMPCCXADD_UNSET): New.
>         (ix86_handle_option): Handle -mcmpccxadd, unset cmpccxadd when avx2
>         is disabled.
>         * common/config/i386/i386-cpuinfo.h (enum processor_features):
>         Add FEATURE_CMPCCXADD.
>         * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
>         cmpccxadd.
>         * config.gcc: Add cmpccxaddintrin.h.
>         * config/i386/cpuid.h (bit_CMPCCXADD): New.
>         * config/i386/i386-builtin-types.def:
>         Add DEF_FUNCTION_TYPE(INT, PINT, INT, INT, INT)
>         and DEF_FUNCTION_TYPE(LONGLONG, PLONGLONG, LONGLONG, LONGLONG, INT).
>         * config/i386/i386-builtin.def (BDESC): Add new builtins.
>         * config/i386/i386-c.cc (ix86_target_macros_internal): Define
>         __CMPCCXADD__.
>         * config/i386/i386-expand.cc (ix86_expand_special_args_builtin):
>         Add new parameter to indicate constant position.
>         Handle INT_FTYPE_PINT_INT_INT_INT
>         and LONGLONG_FTYPE_PLONGLONG_LONGLONG_LONGLONG_INT.
>         * config/i386/i386-isa.def (CMPCCXADD): Add DEF_PTA(CMPCCXADD).
>         * config/i386/i386-options.cc (isa2_opts): Add -mcmpccxadd.
>         (ix86_valid_target_attribute_inner_p): Handle cmpccxadd.
>         * config/i386/i386.opt: Add option -mcmpccxadd.
>         * config/i386/sync.md (cmpccxadd_<mode>): New define insn.
>         * config/i386/x86gprintrin.h: Include cmpccxaddintrin.h.
>         * doc/extend.texi: Document cmpccxadd.
>         * doc/invoke.texi: Document -mcmpccxadd.
>         * doc/sourcebuild.texi: Document target cmpccxadd.
>         * config/i386/cmpccxaddintrin.h: New file.
>
> gcc/testsuite/ChangeLog:
>
>         * g++.dg/other/i386-2.C: Add -mcmpccxadd.
>         * g++.dg/other/i386-3.C: Ditto.
>         * gcc.target/i386/avx-1.c: Add builtin define for enum.
>         * gcc.target/i386/funcspec-56.inc: Add new target attribute.
>         * gcc.target/i386/sse-13.c: Add builtin define for enum.
>         * gcc.target/i386/sse-23.c: Ditto.
>         * gcc.target/i386/x86gprintrin-1.c: Add -mcmpccxadd for 64 bit target.
>         * gcc.target/i386/x86gprintrin-2.c: Add -mcmpccxadd for 64 bit target.
>         Add builtin define for enum.
>         * gcc.target/i386/x86gprintrin-3.c: Add -mcmpccxadd for 64 bit target.
>         * gcc.target/i386/x86gprintrin-4.c: Add mcmpccxadd for 64 bit target.
>         * gcc.target/i386/x86gprintrin-5.c: Add mcpmccxadd for 64 bit target.
>         Add builtin define for enum.
>         * gcc.target/i386/cmpccxadd-1.c: New test.
>         * gcc.target/i386/cmpccxadd-2.c: New test.
> ---
>  gcc/common/config/i386/cpuinfo.h              |   2 +
>  gcc/common/config/i386/i386-common.cc         |  15 ++
>  gcc/common/config/i386/i386-cpuinfo.h         |   1 +
>  gcc/common/config/i386/i386-isas.h            |   1 +
>  gcc/config.gcc                                |   3 +-
>  gcc/config/i386/cmpccxaddintrin.h             |  89 +++++++++++
>  gcc/config/i386/cpuid.h                       |   1 +
>  gcc/config/i386/i386-builtin-types.def        |   4 +
>  gcc/config/i386/i386-builtin.def              |   4 +
>  gcc/config/i386/i386-c.cc                     |   2 +
>  gcc/config/i386/i386-expand.cc                |  22 ++-
>  gcc/config/i386/i386-isa.def                  |   1 +
>  gcc/config/i386/i386-options.cc               |   4 +-
>  gcc/config/i386/i386.opt                      |   5 +
>  gcc/config/i386/sync.md                       |  42 ++++++
>  gcc/config/i386/x86gprintrin.h                |   2 +
>  gcc/doc/extend.texi                           |   5 +
>  gcc/doc/invoke.texi                           |  10 +-
>  gcc/doc/sourcebuild.texi                      |   3 +
>  gcc/testsuite/g++.dg/other/i386-2.C           |   2 +-
>  gcc/testsuite/g++.dg/other/i386-3.C           |   2 +-
>  gcc/testsuite/gcc.target/i386/avx-1.c         |   4 +
>  gcc/testsuite/gcc.target/i386/cmpccxadd-1.c   |  61 ++++++++
>  gcc/testsuite/gcc.target/i386/cmpccxadd-2.c   | 138 ++++++++++++++++++
>  gcc/testsuite/gcc.target/i386/funcspec-56.inc |   2 +
>  gcc/testsuite/gcc.target/i386/sse-13.c        |   6 +-
>  gcc/testsuite/gcc.target/i386/sse-23.c        |   6 +-
>  .../gcc.target/i386/x86gprintrin-1.c          |   2 +-
>  .../gcc.target/i386/x86gprintrin-2.c          |   6 +-
>  .../gcc.target/i386/x86gprintrin-3.c          |   2 +-
>  .../gcc.target/i386/x86gprintrin-4.c          |   2 +-
>  .../gcc.target/i386/x86gprintrin-5.c          |   6 +-
>  gcc/testsuite/lib/target-supports.exp         |  10 ++
>  33 files changed, 450 insertions(+), 15 deletions(-)
>  create mode 100644 gcc/config/i386/cmpccxaddintrin.h
>  create mode 100644 gcc/testsuite/gcc.target/i386/cmpccxadd-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/cmpccxadd-2.c

+;; CMPCCXADD
+
+(define_insn "@cmpccxadd_<mode>_1"
+  [(set (match_operand:SWI48x 1 "register_operand" "+r")
+       (match_operand:SWI48x 0 "memory_operand" "+m"))
+   (set (match_dup 0)
+       (unspec_volatile:SWI48x
+         [(match_dup 0)
+          (match_dup 1)
+          (match_operand:SWI48x 2 "register_operand" "r")
+          (match_operand:SI 3 "const_0_to_15_operand" "n")]
+         UNSPECV_CMPCCXADD))
+   (clobber (reg:CC FLAGS_REG))]
+  "TARGET_CMPCCXADD && TARGET_64BIT"
+{

IMO, the above should be defined much like the existing cmpxchg
pattern (see atomic_compare_and_swap<mode>_1 named pattern), where the
memory operand is updated like the one in xadd pattern
(atomic_fetch_add<mode> named pattern). The above "+r" is not needed
when matched operands are used (see mentioned two patterns). Using
this approach, the expander won't be needed as well, since reload will
take care of the correct input/output operand matching.

Uros.

  parent reply	other threads:[~2022-10-24  9:45 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14  7:54 [PATCH 0/6] Add Intel Sierra Forest Instructions Haochen Jiang
2022-10-14  7:54 ` [PATCH 1/6] Support Intel AVX-IFMA Haochen Jiang
2022-10-19  6:03   ` [PATCH] " Hongyu Wang
2022-10-21  0:52     ` Hongtao Liu
2022-10-14  7:54 ` [PATCH 2/6] Support Intel AVX-VNNI-INT8 Haochen Jiang
2022-10-17  4:05   ` Hongtao Liu
2022-10-17  6:27     ` Jiang, Haochen
2022-10-17  6:30       ` Hongtao Liu
2022-10-18  9:10         ` [PATCH v2] " Haochen Jiang
2022-10-19  1:41           ` Hongtao Liu
2022-10-21  0:53             ` Hongtao Liu
2022-10-14  7:54 ` [PATCH 3/6] i386: Add intrinsic for vector __bf16 Haochen Jiang
2022-10-14  7:54 ` [PATCH 4/6] Support Intel AVX-NE-CONVERT Haochen Jiang
2022-10-17  5:46   ` Hongtao Liu
2022-10-24  6:20     ` Kong, Lingling
2022-10-25  5:23       ` Hongtao Liu
2022-10-28  8:57         ` Kong, Lingling
2022-10-31  1:05           ` Liu, Hongtao
2022-10-14  7:54 ` [PATCH 5/6] Support Intel CMPccXADD Haochen Jiang
2022-10-24  9:01   ` [PATCH] " Haochen Jiang
2022-10-24  9:04     ` Jiang, Haochen
2022-10-24  9:44     ` Uros Bizjak [this message]
2022-11-03  6:26       ` Haochen Jiang
2022-11-03  7:47         ` Uros Bizjak
2022-10-14  7:54 ` [PATCH 6/6] Initial Sierra Forest Support Haochen Jiang
2022-11-03  6:31   ` Hongtao Liu
2022-10-14  8:14 ` [PATCH 0/6] Add Intel Sierra Forest Instructions Iain Sandoe
2022-10-14  8:20   ` Hongtao Liu
2022-10-14  8:24     ` Iain Sandoe
2022-10-14  8:30       ` Hongtao Liu
2022-10-14  8:36         ` Iain Sandoe
2022-10-17  1:02           ` Hongtao Liu
2022-10-17  1:30             ` Bernhard Reutner-Fischer
2022-10-17  1:56               ` Hongtao Liu
2022-10-19 11:09                 ` Iain Sandoe
2022-10-20  1:11                   ` Hongtao Liu
2022-10-20  9:09                     ` Hongtao Liu
2022-10-20  9:17                       ` Iain Sandoe
2022-10-20  9:20                         ` Hongtao Liu
2022-10-20 15:23                           ` Iain Sandoe
2022-10-21  0:06                             ` Hongtao Liu
2022-10-14  8:35       ` Hongtao Liu
2022-10-18  9:17 ` [PATCH] i386: Auto vectorize sdot_prod, udot_prod with VNNIINT8 instruction Haochen Jiang
2022-10-19  1:43   ` Hongtao Liu
2022-10-21  0:54     ` Hongtao Liu

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='CAFULd4YraK=YDLxSZFfSNKkRqA9Ttt_E_a94Cq7UxeU0TijqbA@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=haochen.jiang@intel.com \
    --cc=hongtao.liu@intel.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).