From patchwork Wed Nov 1 10:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 160500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp304248vqx; Wed, 1 Nov 2023 03:11:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5FrpfgpqYLTV1b0iotXPiHmie7SfJGu+PAgFIKdwO9MWIxKun5FiE4QmAw/IYH83fHNQ/ X-Received: by 2002:a05:6214:27c2:b0:66c:ffe1:e244 with SMTP id ge2-20020a05621427c200b0066cffe1e244mr15809834qvb.62.1698833464191; Wed, 01 Nov 2023 03:11:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698833464; cv=pass; d=google.com; s=arc-20160816; b=Gz7qKDpvtE2wxnmvSZN4kC86r4Dqyx8pg57nyruDiyJsCbzeA6ikcxrxP3sFq0F6OW Lp9BftngfnVe5bAGuX//zkPdt4UEHBTZrn4oAlPfKs9LDnJneRckZs4jurE1gLBPTsEw rKI2OjMn57/TfuLGnoU/KXh0vTQaSXoZHU44o30BfQ6Jh6z+2owV99UTgYwDcVY2/naE cD1ZTHTPJ4XUbW3TMBdMdBdtGvlvm7SB0uP9ghdaTrgKDMjhhV6PTMkYmSPNqqpriA50 odFGTZncnOUWtAUaf2VJbMFQ1eYwb9f6cLLa5SCYvTvJ85Rr4/6u61E0jXP5xLKcZXgI FPlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=3tV+kfIrbFu4aebS/Auar+U2R40RPHYfclrf5/YaXAI=; fh=ChXOctppJn0KECDRINafwUY5xHRufGHaa0Ju9pddrcQ=; b=CvKy/vjVRDj59PbRIoKskT316vvZS6yAoXbbIJV8+Pvy0+tI9PhYEZmN2bIaK174cZ cTodSNzo+eEzpIrHa6Psw4mICKPXOSseSAuQdywYMKyRyipIiDUspXqr9YOwQJar98vI 5ZZ4W1VD4XWQOHUreXz/BSSf+4F41FaUqHSEE58hIly0VhzXDUlno9hpOyfRC9R4HwWb 5VGhsM/Jh81d6RPbRH63qmk860f8/yCBn3dWKL+nFsR+sYm/u3EQzrEmh4YZXAPbg01l T8zUSDmneEVoWfClleYhp4KSwol8hOxS6JCBtgpAOybm3I3GnI5NUZ6Gcjm8DjmWw5Mc p/GQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K4s8VXij; arc=pass (i=1); 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=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r2-20020a05620a298200b007759bc40d84si570852qkp.406.2023.11.01.03.11.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:11:04 -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=@intel.com header.s=Intel header.b=K4s8VXij; arc=pass (i=1); 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=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA887385B537 for ; Wed, 1 Nov 2023 10:11:03 +0000 (GMT) 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.100]) by sourceware.org (Postfix) with ESMTPS id 0658C3858C00 for ; Wed, 1 Nov 2023 10:10:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0658C3858C00 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0658C3858C00 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.100 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698833437; cv=none; b=ZkhFxjOjKNbv60utbY8zisO6FjY8lX8lGOhSlu/xvN0BoWHzwOe2qqHOSudM8QSruqUyJCAgOLA2rzW0tiaB0XDpaTCcqkYVWUsJujF+MvnAZcI2bkXKu+a8hJuf4oSc6yrMseOd+kQbBOqCjt/5qT5X8lbPOhBBNHFG7cJ7hMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698833437; c=relaxed/simple; bh=v9QRuYh/SDy/TMEKfuiw7IqgcK6RA4Bx5BO0yCdjJLI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=jQALyqG5V0Wa3MtgAeaZ5qubQh38+sTpWn0tUZ7g9L5yNswyCKCkoocosCss87lC1jBUhqcyz0lImlp0WHUgRde7b3WPSQey+qRCCoKzwY0R1/UnYtWgeB0/v3H7E8x6g4/lE7csv9z+8yZYNlREkliG8ovIfGonqXHea0mmbjk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698833427; x=1730369427; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=v9QRuYh/SDy/TMEKfuiw7IqgcK6RA4Bx5BO0yCdjJLI=; b=K4s8VXijlTc+/JT7yFzG+WQatWY2m3gAgNi+7Ri2XzQ7+KW+/o+LeDbe gcPAnBVazAVH9H4HXU6DpPunoz82Rg7GqpN9fCFDgCUWUZqIAsXxrKvAj Zw8A4NCYaOMLlH9qAEOHklj3H8mhyc3Qm8VYLHmPutOV50InFqqMlpG8e fGrAAtw464k7s+UqIQs7ZQlcgjqh6DrNHEikwMua8UVHbYmpAyc69XnyV bqX+euL70xUC1WPWwy7Rcv4gQvwDcIegxJgARF8ROBBYzhrHoaMJ6JQdz Ubz/LVvq/G2OEwbHPbB7vZNt42A3KeK0ZCaDMESP4yWKnEcSEKzDgihYk w==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="454944906" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="454944906" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:10:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="710742408" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="710742408" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga003.jf.intel.com with ESMTP; 01 Nov 2023 03:10:22 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 327BE10056B3; Wed, 1 Nov 2023 18:10:22 +0800 (CST) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] Support cmul{_conj}v4hf3/cmla{_conj}v4hf4 with AVX512FP16 instruction. Date: Wed, 1 Nov 2023 18:08:22 +0800 Message-Id: <20231101100822.2126091-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 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, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781355998501630356 X-GMAIL-MSGID: 1781355998501630356 Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,} Ready push to trunk. gcc/ChangeLog: * config/i386/mmx.md (cmlav4hf4): New expander. (cmla_conjv4hf4): Ditto. (cmulv4hf3): Ditto. (cmul_conjv4hf3): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/part-vect-complexhf.c: New test. --- gcc/config/i386/mmx.md | 86 +++++++++++++++++++ .../gcc.target/i386/part-vect-complexhf.c | 40 +++++++++ 2 files changed, 126 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/part-vect-complexhf.c diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index 2b97bb8fa98..ba81ff72551 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -2622,6 +2622,92 @@ (define_expand "vec_fmsubaddv4hf4" DONE; }) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Parallel half-precision floating point complex type operations +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define_expand "cmlav4hf4" + [(match_operand:V4HF 0 "register_operand") + (match_operand:V4HF 1 "vector_operand") + (match_operand:V4HF 2 "vector_operand") + (match_operand:V4HF 3 "vector_operand")] + "TARGET_AVX512FP16 && TARGET_AVX512VL" +{ + rtx op3 = gen_reg_rtx (V8HFmode); + rtx op2 = gen_reg_rtx (V8HFmode); + rtx op1 = gen_reg_rtx (V8HFmode); + rtx op0 = gen_reg_rtx (V8HFmode); + + emit_insn (gen_movq_v4hf_to_sse (op3, operands[3])); + emit_insn (gen_movq_v4hf_to_sse (op2, operands[2])); + emit_insn (gen_movq_v4hf_to_sse (op1, operands[1])); + + emit_insn (gen_cmlav8hf4 (op0, op1, op2, op3)); + + emit_move_insn (operands[0], lowpart_subreg (V4HFmode, op0, V8HFmode)); + DONE; +}) + +(define_expand "cmla_conjv4hf4" + [(match_operand:V4HF 0 "register_operand") + (match_operand:V4HF 1 "vector_operand") + (match_operand:V4HF 2 "vector_operand") + (match_operand:V4HF 3 "vector_operand")] + "TARGET_AVX512FP16 && TARGET_AVX512VL" +{ + rtx op3 = gen_reg_rtx (V8HFmode); + rtx op2 = gen_reg_rtx (V8HFmode); + rtx op1 = gen_reg_rtx (V8HFmode); + rtx op0 = gen_reg_rtx (V8HFmode); + + emit_insn (gen_movq_v4hf_to_sse (op3, operands[3])); + emit_insn (gen_movq_v4hf_to_sse (op2, operands[2])); + emit_insn (gen_movq_v4hf_to_sse (op1, operands[1])); + + emit_insn (gen_cmla_conjv8hf4 (op0, op1, op2, op3)); + + emit_move_insn (operands[0], lowpart_subreg (V4HFmode, op0, V8HFmode)); + DONE; +}) + +(define_expand "cmulv4hf3" + [(match_operand:V4HF 0 "register_operand") + (match_operand:V4HF 1 "vector_operand") + (match_operand:V4HF 2 "vector_operand")] + "TARGET_AVX512FP16 && TARGET_AVX512VL" +{ + rtx op2 = gen_reg_rtx (V8HFmode); + rtx op1 = gen_reg_rtx (V8HFmode); + rtx op0 = gen_reg_rtx (V8HFmode); + + emit_insn (gen_movq_v4hf_to_sse (op2, operands[2])); + emit_insn (gen_movq_v4hf_to_sse (op1, operands[1])); + + emit_insn (gen_cmulv8hf3 (op0, op1, op2)); + emit_move_insn (operands[0], lowpart_subreg (V4HFmode, op0, V8HFmode)); + DONE; +}) + +(define_expand "cmul_conjv4hf3" + [(match_operand:V4HF 0 "register_operand") + (match_operand:V4HF 1 "vector_operand") + (match_operand:V4HF 2 "vector_operand")] + "TARGET_AVX512FP16 && TARGET_AVX512VL" +{ + rtx op2 = gen_reg_rtx (V8HFmode); + rtx op1 = gen_reg_rtx (V8HFmode); + rtx op0 = gen_reg_rtx (V8HFmode); + + emit_insn (gen_movq_v4hf_to_sse (op2, operands[2])); + emit_insn (gen_movq_v4hf_to_sse (op1, operands[1])); + + emit_insn (gen_cmul_conjv8hf3 (op0, op1, op2)); + emit_move_insn (operands[0], lowpart_subreg (V4HFmode, op0, V8HFmode)); + DONE; +}) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Parallel half-precision floating point conversion operations diff --git a/gcc/testsuite/gcc.target/i386/part-vect-complexhf.c b/gcc/testsuite/gcc.target/i386/part-vect-complexhf.c new file mode 100644 index 00000000000..b9f4ba2f4cf --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/part-vect-complexhf.c @@ -0,0 +1,40 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O1 -ftree-vectorize -ffast-math -mavx512fp16 -mavx512vl" } */ +/* { dg-final { scan-assembler-times "vfmaddcph\[ \\t\]" 1 } } */ +/* { dg-final { scan-assembler-not "vfmadd\[123]*ph\[ \\t\]"} } */ +/* { dg-final { scan-assembler-not "vfmadd\[123]*sh\[ \\t\]"} } */ +/* { dg-final { scan-assembler-times "vfcmaddcph\[ \\t\]" 1 } } */ +/* { dg-final { scan-assembler-times "vfmulcph\[ \\t\]" 1 } } */ +/* { dg-final { scan-assembler-times "vfcmulcph\[ \\t\]" 1 } } */ + +#include +#define TYPE _Float16 +#define N 2 + +void fma0 (_Complex TYPE *a, _Complex TYPE *b, + _Complex TYPE * __restrict c) +{ + for (int i = 0; i < N; i++) + c[i] += a[i] * b[i]; +} + +void fmaconj (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i = 0; i < N; i++) + c[i] += a[i] * ~b[i]; +} + +void fmul (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i = 0; i < N; i++) + c[i] = a[i] * b[i]; +} + +void fmulconj (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i = 0; i < N; i++) + c[i] = a[i] * ~b[i]; +}