From patchwork Mon Sep 11 01:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 137867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1817004vqo; Sun, 10 Sep 2023 18:17:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgU/QT3hQdLyKipE+BadZ3QAFvGKhpPmqYRW/zj0RvYxkOUCGJwyQ/7K4zOAqNzAaJ1fZj X-Received: by 2002:aa7:d7d3:0:b0:525:3e99:8ab9 with SMTP id e19-20020aa7d7d3000000b005253e998ab9mr7093275eds.10.1694395020596; Sun, 10 Sep 2023 18:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694395020; cv=none; d=google.com; s=arc-20160816; b=eq/SAJBoQfX8At/UFQdoKnDAX0U2b+yf5CpqkIL7t/mLi757B0/C10ID0lzvMIE7KZ N2AmMqkHP4bjZwRYidCEt32OXXOR/YcOX3lQgbE5ltNuZTl23xn3ht7anYNnW1L/vXbG pNcZ3Hc8CV8DrkKxiDs87bNhfEnnUv78irjpuPcVsmzCMKnr1dBWYO+C8011IYGRN+PT 6ATclD1kvZinEgioOVrgoZyMEbHTbWps7QAOsEFmnNGYRimY/SekDPW2x7TUpUGnrSbv wA6XetRuBnP17lZivfpX87kTdb81IojnBjnyMlWctbejw6x88IcXrcQ1lIhvDr+J4oD7 JgHQ== 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:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=BLXTkVW5IJbkGyCug85/RaJFXtzDj+MmaqzRA7OzqY4=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=nSn1qUJZ+kj2LEohBPrpVwmLp0DTwrQphFO37lLh6GgO2eyM8c6hiuSTYUL68y/Pkv izkoYp5hrAPMMJ05WVTt41YuXTrjcr1Qb6VRVwnAeRf3M5sP9fksyAhwCBmCvK9phcMA UWuoVApee7QRiRwC41mq+yZTj05Z9EbFC8Xe+ZVUSap25RQ9cdIjrrktHx5A7LLKky0i sVjzUAXkC8kA0osOk4F8WgVAbp3mCk9PC8fUKRx59kjcRDuUKRyaTT4JfBw7g+02qpAY 6RZBlIgfDauNDyYgyMOrJXdCgF/OZX9TjBNAmBtoobFzNh+AKr13P4bngTV8XlnPu3+K kvVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OlIg0RjJ; 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 ba9-20020a0564021ac900b0052a408de675si5472019edb.466.2023.09.10.18.17.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Sep 2023 18:17:00 -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=OlIg0RjJ; 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 2008F3858C30 for ; Mon, 11 Sep 2023 01:16:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2008F3858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694395019; bh=BLXTkVW5IJbkGyCug85/RaJFXtzDj+MmaqzRA7OzqY4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OlIg0RjJx0eZp3k+zlOCBhgi71j9oCC00myoRKrJeFdehC2ZimfCdJB7M7vx8NDV/ leHawbTnXNpKZQ8M1B9uUiOOi538Tdsuq3MPpKEVOZHwoNQpdkWJU4GNqTnXr+m+LS Z8Sde3IPUkqJDQ/5mE/LWbyu4QTSFblsUDRzwfDY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id AA43A3858D3C for ; Mon, 11 Sep 2023 01:16:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA43A3858D3C X-IronPort-AV: E=McAfee;i="6600,9927,10829"; a="368208197" X-IronPort-AV: E=Sophos;i="6.02,243,1688454000"; d="scan'208";a="368208197" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2023 18:16:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10829"; a="989905947" X-IronPort-AV: E=Sophos;i="6.02,243,1688454000"; d="scan'208";a="989905947" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga006.fm.intel.com with ESMTP; 10 Sep 2023 18:16:08 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 0BE631005686; Mon, 11 Sep 2023 09:16:08 +0800 (CST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove constraint modifier % for fcmaddcph/fmaddcph/fcmulcph since there're not commutative. Date: Mon, 11 Sep 2023 09:16:08 +0800 Message-Id: <20230911011608.312795-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230908031918.1035385-1-hongtao.liu@intel.com> References: <20230908031918.1035385-1-hongtao.liu@intel.com> 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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: 1776701953109715632 X-GMAIL-MSGID: 1776701953109715632 Here's the patch I've commited. The patch also remove % for vfmaddcph. gcc/ChangeLog: PR target/111306 PR target/111335 * 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..14615999394 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 (); + } +} + +