From patchwork Fri Sep 8 03:19:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 137694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp291619vqo; Thu, 7 Sep 2023 20:22:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7SmoPwMc8TRtE38C63nVde0cpBkgNOvmIgSQDlCyYBMFTy8PVt7Po9DW1L9I0RsdjkpaG X-Received: by 2002:a17:906:8458:b0:99b:4210:cc76 with SMTP id e24-20020a170906845800b0099b4210cc76mr1076371ejy.28.1694143328857; Thu, 07 Sep 2023 20:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694143328; cv=none; d=google.com; s=arc-20160816; b=bEQa8igL3SCbRCSRxq1Y/a077zQAKfh5u5RcbJQGntwk2WenRQ+v9FVp0b9LfNVBL8 8ftND1V5s3TxN40hWkzmLSbCpHJtDW6aQHfnQ0AQLt4/sG5gYcw4fu8BXOsjOujN68GS Avxt+gTv3aaNAtYudflkmw68wlM3CiseLqdUhr7cDyLwZxxEB35Io3DrN/bxr9wwVGpN XD4VSMrLVi8IbOeGRJqaDrfFtLJnBkiZXu8OF8uKphLIYhO4vWTsd4fNHEItRx8xhW5T 9H5KazmXTbKuqiF0zKpfL9DD/zloYhRx0w6chzvDQ56PGNl3Vb+RHbrTRUrHQVuVPeYs Fw3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=6QRpwcftDNfM5g+cYzGe3HHeyGk8qTEHvMMj5V8qVxQ=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=Kmz9NlhfN89RID3gqfdV0/jnAE5y3+v9S+X+oXD2GMO9F2nSun8uVCTxA04sS9Niyk aRNtD+8kY9J9sLrKo6UEvhhus0xRbPktpNJIGWHffZwo+4lkzzv/xhOUH9hNCWNCrX3S kyucZRixEfqwYSi77cu0P/esNtJnYY0NFFVTF9D/HRnp4qqSYdozRwGymaHRJaNo7L44 CHSuOkZ6m9N/J3XlHvKjRGrdBOomqqhSu73+LfeiK6A93VBlagJdlX0alZjRmkrUJj2v GiRw9E6n3HZW8hDrJGTtvaLSx+maU2vgiFClmxPuApR2WSip9HZ3jNqBCfv6wVVW5GTx hMLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FsTaauYL; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r26-20020a170906c29a00b0098dafe075ccsi534339ejz.97.2023.09.07.20.22.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 20:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FsTaauYL; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70E133858D1E for ; Fri, 8 Sep 2023 03:22:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70E133858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694143327; bh=6QRpwcftDNfM5g+cYzGe3HHeyGk8qTEHvMMj5V8qVxQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FsTaauYLOOCMLrEopzuznrV/hXn6C6fKjfSBgcu5S48rFZ1MQvVECiXx87j8noAYF ye1oyvep0VMYAyNekwY+NI6dXWv0kAvzW3NnhFecYAFsxOleMAy+Bsd67TFVzCoyKe PQc9eoL9/uJMOl8yjnFzRMnORPI01CbCrh8S3C3Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 35D5F3858D1E for ; Fri, 8 Sep 2023 03:21:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35D5F3858D1E X-IronPort-AV: E=McAfee;i="6600,9927,10826"; a="463921945" X-IronPort-AV: E=Sophos;i="6.02,236,1688454000"; d="scan'208";a="463921945" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2023 20:21:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10826"; a="742306458" X-IronPort-AV: E=Sophos;i="6.02,236,1688454000"; d="scan'208";a="742306458" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga002.jf.intel.com with ESMTP; 07 Sep 2023 20:21:19 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id CEA621005705; Fri, 8 Sep 2023 11:21:18 +0800 (CST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove constraint modifier % for fcmaddcph/fcmulcph since there're not commutative. Date: Fri, 8 Sep 2023 11:19:18 +0800 Message-Id: <20230908031918.1035385-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: liuhongt via Gcc-patches From: liuhongt Reply-To: liuhongt Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776438035614694935 X-GMAIL-MSGID: 1776438035614694935 Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,} on SPR. Ready push to trunk and backport to GCC13/GCC12. gcc/ChangeLog: PR target/111306 * config/i386/sse.md (int_comm): New int_attr. (fma__): Remove % for Complex conjugate operations since they're not commutative. (fma___pair): Ditto. (___mask): Ditto. (cmul3): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/pr111306.c: New test. --- gcc/config/i386/sse.md | 16 ++++++++--- gcc/testsuite/gcc.target/i386/pr111306.c | 36 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr111306.c diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 6d3ae8dea0c..833546c5228 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -6480,6 +6480,14 @@ (define_int_attr complexpairopname [(UNSPEC_COMPLEX_FMA_PAIR "fmaddc") (UNSPEC_COMPLEX_FCMA_PAIR "fcmaddc")]) +(define_int_attr int_comm + [(UNSPEC_COMPLEX_FMA "%") + (UNSPEC_COMPLEX_FMA_PAIR "%") + (UNSPEC_COMPLEX_FCMA "") + (UNSPEC_COMPLEX_FCMA_PAIR "") + (UNSPEC_COMPLEX_FMUL "%") + (UNSPEC_COMPLEX_FCMUL "")]) + (define_int_attr conj_op [(UNSPEC_COMPLEX_FMA "") (UNSPEC_COMPLEX_FCMA "_conj") @@ -6593,7 +6601,7 @@ (define_expand "cmla4" (define_insn "fma__" [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v") (unspec:VHF_AVX512VL - [(match_operand:VHF_AVX512VL 1 "" "%v") + [(match_operand:VHF_AVX512VL 1 "" "v") (match_operand:VHF_AVX512VL 2 "" "") (match_operand:VHF_AVX512VL 3 "" "0")] UNSPEC_COMPLEX_F_C_MA))] @@ -6658,7 +6666,7 @@ (define_insn_and_split "fma___fma_zero" (define_insn "fma___pair" [(set (match_operand:VF1_AVX512VL 0 "register_operand" "=&v") (unspec:VF1_AVX512VL - [(match_operand:VF1_AVX512VL 1 "vector_operand" "%v") + [(match_operand:VF1_AVX512VL 1 "vector_operand" "v") (match_operand:VF1_AVX512VL 2 "bcst_vector_operand" "vmBr") (match_operand:VF1_AVX512VL 3 "vector_operand" "0")] UNSPEC_COMPLEX_F_C_MA_PAIR))] @@ -6727,7 +6735,7 @@ (define_insn "___mask" [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v") (vec_merge:VHF_AVX512VL (unspec:VHF_AVX512VL - [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "%v") + [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "v") (match_operand:VHF_AVX512VL 2 "nonimmediate_operand" "") (match_operand:VHF_AVX512VL 3 "register_operand" "0")] UNSPEC_COMPLEX_F_C_MA) @@ -6752,7 +6760,7 @@ (define_expand "cmul3" (define_insn "__" [(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v") (unspec:VHF_AVX512VL - [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "%v") + [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "v") (match_operand:VHF_AVX512VL 2 "nonimmediate_operand" "")] UNSPEC_COMPLEX_F_C_MUL))] "TARGET_AVX512FP16 && " diff --git a/gcc/testsuite/gcc.target/i386/pr111306.c b/gcc/testsuite/gcc.target/i386/pr111306.c new file mode 100644 index 00000000000..541725ebdad --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr111306.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512fp16 -mavx512vl" } */ +/* { dg-require-effective-target avx512fp16 } */ + +#define AVX512FP16 +#include "avx512f-helper.h" + +__attribute__((optimize("O2"),noipa)) +void func1(_Float16 *a, _Float16 *b, int n, _Float16 *c) { + __m512h rA = _mm512_loadu_ph(a); + for (int i = 0; i < n; i += 32) { + __m512h rB = _mm512_loadu_ph(b + i); + _mm512_storeu_ph(c + i, _mm512_fcmul_pch(rB, rA)); + } +} + +void +test_512 (void) +{ + int n = 32; + _Float16 a[n], b[n], c[n]; + _Float16 exp[n]; + for (int i = 1; i <= n; i++) { + a[i - 1] = i & 1 ? -i : i; + b[i - 1] = i; + } + + func1(a, b, n, c); + for (int i = 0; i < n / 32; i += 2) { + if (c[i] != a[i] * b[i] + a[i+1] * b[i+1] + || c[i+1] != a[i] * b[i+1] - a[i+1]*b[i]) + __builtin_abort (); + } +} + +