From patchwork Mon Oct 23 08:48:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 156753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1157055vqx; Mon, 23 Oct 2023 01:48:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXWogOnS/tb3lERAPYk2eV3lsx/oC15kiOcKR0RvSqxfrAHTblB/3NQAEkdccNrI+8JTAB X-Received: by 2002:ac8:7d84:0:b0:419:5162:5e0f with SMTP id c4-20020ac87d84000000b0041951625e0fmr9073304qtd.13.1698050917131; Mon, 23 Oct 2023 01:48:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698050917; cv=pass; d=google.com; s=arc-20160816; b=ZVl3BZSbXdyG8PTJFnzNCAK+a93ZMq6EB4YhbA+tJMauub9GUu8DTrfpY7xXBE6ArU WkjSc0gW6diruTs2rFkCQaoeZxPyLjqO7eoDkBZ6ow0WLbhrgkZtO1I6njRsaMYTTBXm H8ncbWeue2rF+QFoS3ZkUlk0trC5akmnghVWp7PL7O8GgQ1u55qbXgsAj4t7LHwHIRE9 zxqsvNOInPIwGgEuH+TOWtPO2MrhIl0NUxg7kJR0a6dRJTiNErRqMeWdsxxOiMJfFVYP 86YRRJOGV1aUUbM8tRbng+nVdYgj6LFz3KAHCMdiiDDkO10vmBTIOmPJaq9g53vkU4oU 8BfA== 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=Zyxsk4neBAOoMFpYJ8QhU6SwGOhNHgS23ihn88KqPu0=; fh=ChXOctppJn0KECDRINafwUY5xHRufGHaa0Ju9pddrcQ=; b=lCbW92TWV7OQxBIrNQRlJbLhsVgNMqgx3IMNhQa37KIMReJh9ia01Fcr9gMAHD7yLw 245h885W0p3R6taJ8MRgxC7O/MWXCQVbelkIT6l21tuwDDyCzL+ZGX6aOj2FKwUGfivC MgXQWcNk0OMCbnqkOHkkBoM8m4ryP3jQO/N32MOSx1nqOUrFAKgzzo1jmU2lANQyg8EA hKiTjS9j0vFvpF4GSvauXazIJmNSTSUsH0uo6xavzJU9oavyatJFfhDyPiGm+3qWPVX8 Eq3EFIok/Bh8mCkLmRsAaNgvVXp1AhYZeTMj7vJbK9+197BoqtoVFHJafCgB/Tv7jOLq jucg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dzG1hfb6; 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 f21-20020ac85d15000000b00418122a226bsi5145122qtx.182.2023.10.23.01.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 01:48:37 -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=dzG1hfb6; 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 DFD8C3858CDB for ; Mon, 23 Oct 2023 08:48:36 +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 [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id AFFC83858D37 for ; Mon, 23 Oct 2023 08:48:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFFC83858D37 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 AFFC83858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.55.52.120 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698050890; cv=none; b=JmB4VHX04sHdtvbJKd5e3dlpBNCx7IfGAmUMDuiUCaXASl0iWXOl7uJQadigk48G+HXv96+6NmWw7rNnl297ZeLE2qI5q87TkEpp1G/d31n81SBP2QncmWbcZZ0EH4OpgUXQRw5oGeUV489GGFS5Itj8KMzLRgKK5jR6Qjnf4pM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698050890; c=relaxed/simple; bh=xHHPxZH66aPaC4E/Fqat3zQBrW0uAgZWzPPZcTr/65Q=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=x6nn+vLB6hgjspxm+9YAYl2APci6bW0X+ic+vCaQrNVoAkNqdI9PvfE4+sF2qLFY6mWy8zzBRrRFg73FYjmJBg4LeydQ+TD9rA1k/qQRrK3CYEymR6rQ2phb+/paE72c0OGWqlRrRaCvcrIgBLVmvLut/YwuBtG3aFHzf/NjZKU= 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=1698050887; x=1729586887; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xHHPxZH66aPaC4E/Fqat3zQBrW0uAgZWzPPZcTr/65Q=; b=dzG1hfb6hQqjrHmWmgs//I0hsrsnzGlRyrXEaMvzEg3zfHeIXG36NoYb z0Hj8mfIDoC7gJ/nzYZyUvbV5UJLPl2DFpy4oaZAm83EzpXoCZJStwfFx yyTtIGP4MRJ0bKMcCHfRTe15cDdwDEatX2s7zGTR9CJljBHNwfoJqUpH8 OdtFtHSU9A6qsh6D2bQZWN8aDQVmcYC/IdQ6NJyQM909jS9kWYjD8I4WY aM/G2N7oIzkaBJeluYz9DRO3hW1fzLAqdnvSfoVVjdXIRobIlDKPC/eg4 r6iLmBm7Irbbnne8yEmvs9lC7uoAvi6m6PxfoXZCBzrRJmGYUzIchmbP7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10871"; a="385678083" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="385678083" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2023 01:48:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10871"; a="901747219" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="901747219" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga001.fm.intel.com with ESMTP; 23 Oct 2023 01:45:47 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 1A57310056FC; Mon, 23 Oct 2023 16:48:03 +0800 (CST) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] Support vec_cmpmn/vcondmn for v2hf/v4hf. Date: Mon, 23 Oct 2023 16:48:03 +0800 Message-Id: <20231023084803.1600456-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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780535438248266319 X-GMAIL-MSGID: 1780535438248266319 Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ready push to trunk. gcc/ChangeLog: PR target/103861 * config/i386/i386-expand.cc (ix86_expand_sse_movcc): Handle V2HF/V2BF/V4HF/V4BFmode. * config/i386/mmx.md (vec_cmpv4hfqi): New expander. (vcondv4hf): Ditto. (vcondv4hi): Ditto. (vconduv4hi): Ditto. (vcond_mask_v4hi): Ditto. (vcond_mask_qi): Ditto. (vec_cmpv2hfqi): Ditto. (vcondv2hf): Ditto. (vcondv2hi): Ditto. (vconduv2hi): Ditto. (vcond_mask_v2hi): Ditto. * config/i386/sse.md (vcond): Merge this with .. (vcond): .. this into .. (vcond): .. this, and extend to V8BF/V16BF/V32BFmode. gcc/testsuite/ChangeLog: * g++.target/i386/part-vect-vcondhf.C: New test. * gcc.target/i386/part-vect-vec_cmphf.c: New test. --- gcc/config/i386/i386-expand.cc | 4 + gcc/config/i386/mmx.md | 237 +++++++++++++++++- gcc/config/i386/sse.md | 25 +- .../g++.target/i386/part-vect-vcondhf.C | 34 +++ .../gcc.target/i386/part-vect-vec_cmphf.c | 26 ++ 5 files changed, 304 insertions(+), 22 deletions(-) create mode 100644 gcc/testsuite/g++.target/i386/part-vect-vcondhf.C create mode 100644 gcc/testsuite/gcc.target/i386/part-vect-vec_cmphf.c diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 1eae9d7c78c..9658f9c5a2d 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -4198,6 +4198,8 @@ ix86_expand_sse_movcc (rtx dest, rtx cmp, rtx op_true, rtx op_false) break; case E_V8QImode: case E_V4HImode: + case E_V4HFmode: + case E_V4BFmode: case E_V2SImode: if (TARGET_SSE4_1) { @@ -4207,6 +4209,8 @@ ix86_expand_sse_movcc (rtx dest, rtx cmp, rtx op_true, rtx op_false) break; case E_V4QImode: case E_V2HImode: + case E_V2HFmode: + case E_V2BFmode: if (TARGET_SSE4_1) { gen = gen_mmx_pblendvb_v4qi; diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index 491a0a51272..b9617e9d8c6 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -61,6 +61,9 @@ (define_mode_iterator MMXMODE248 [V4HI V2SI V1DI]) (define_mode_iterator V_32 [V4QI V2HI V1SI V2HF V2BF]) (define_mode_iterator V2FI_32 [V2HF V2BF V2HI]) +(define_mode_iterator V4FI_64 [V4HF V4BF V4HI]) +(define_mode_iterator V4F_64 [V4HF V4BF]) +(define_mode_iterator V2F_32 [V2HF V2BF]) ;; 4-byte integer vector modes (define_mode_iterator VI_32 [V4QI V2HI]) @@ -1972,10 +1975,12 @@ (define_mode_attr mov_to_sse_suffix [(V2HF "d") (V4HF "q") (V2HI "d") (V4HI "q")]) (define_mode_attr mmxxmmmode - [(V2HF "V8HF") (V2HI "V8HI") (V2BF "V8BF")]) + [(V2HF "V8HF") (V2HI "V8HI") (V2BF "V8BF") + (V4HF "V8HF") (V4HI "V8HI") (V4BF "V8BF")]) (define_mode_attr mmxxmmmodelower - [(V2HF "v8hf") (V2HI "v8hi") (V2BF "v8bf")]) + [(V2HF "v8hf") (V2HI "v8hi") (V2BF "v8bf") + (V4HF "v8hf") (V4HI "v8hi") (V4BF "v8bf")]) (define_expand "movd__to_sse" [(set (match_operand: 0 "register_operand") @@ -2114,6 +2119,234 @@ (define_insn_and_split "*mmx_nabs2" [(set (match_dup 0) (ior: (match_dup 1) (match_dup 2)))]) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Parallel half-precision floating point comparisons +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define_expand "vec_cmpv4hfqi" + [(set (match_operand:QI 0 "register_operand") + (match_operator:QI 1 "" + [(match_operand:V4HF 2 "nonimmediate_operand") + (match_operand:V4HF 3 "nonimmediate_operand")]))] + "TARGET_MMX_WITH_SSE && TARGET_AVX512FP16 && TARGET_AVX512VL + && ix86_partial_vec_fp_math" +{ + rtx ops[4]; + ops[3] = gen_reg_rtx (V8HFmode); + ops[2] = gen_reg_rtx (V8HFmode); + + emit_insn (gen_movq_v4hf_to_sse (ops[3], operands[3])); + emit_insn (gen_movq_v4hf_to_sse (ops[2], operands[2])); + emit_insn (gen_vec_cmpv8hfqi (operands[0], operands[1], ops[2], ops[3])); + DONE; +}) + +(define_expand "vcondv4hf" + [(set (match_operand:V4FI_64 0 "register_operand") + (if_then_else:V4FI_64 + (match_operator 3 "" + [(match_operand:V4HF 4 "nonimmediate_operand") + (match_operand:V4HF 5 "nonimmediate_operand")]) + (match_operand:V4FI_64 1 "general_operand") + (match_operand:V4FI_64 2 "general_operand")))] + "TARGET_AVX512FP16 && TARGET_AVX512VL + && TARGET_MMX_WITH_SSE && ix86_partial_vec_fp_math" +{ + rtx ops[6]; + ops[5] = gen_reg_rtx (V8HFmode); + ops[4] = gen_reg_rtx (V8HFmode); + ops[0] = gen_reg_rtx (mode); + ops[1] = lowpart_subreg (mode, + force_reg (mode, operands[1]), + mode); + ops[2] = lowpart_subreg (mode, + force_reg (mode, operands[2]), + mode); + ops[3] = operands[3]; + emit_insn (gen_movq_v4hf_to_sse (ops[4], operands[4])); + emit_insn (gen_movq_v4hf_to_sse (ops[5], operands[5])); + bool ok = ix86_expand_fp_vcond (ops); + gcc_assert (ok); + + emit_move_insn (operands[0], lowpart_subreg (mode, ops[0], + mode)); + DONE; +}) + +(define_expand "vcondv4hi" + [(set (match_operand:V4F_64 0 "register_operand") + (if_then_else:V4F_64 + (match_operator 3 "" + [(match_operand:V4HI 4 "nonimmediate_operand") + (match_operand:V4HI 5 "nonimmediate_operand")]) + (match_operand:V4F_64 1 "general_operand") + (match_operand:V4F_64 2 "general_operand")))] + "TARGET_MMX_WITH_SSE && TARGET_SSE4_1" +{ + bool ok = ix86_expand_int_vcond (operands); + gcc_assert (ok); + DONE; +}) + +(define_expand "vconduv4hi" + [(set (match_operand:V4F_64 0 "register_operand") + (if_then_else:V4F_64 + (match_operator 3 "" + [(match_operand:V4HI 4 "nonimmediate_operand") + (match_operand:V4HI 5 "nonimmediate_operand")]) + (match_operand:V4F_64 1 "general_operand") + (match_operand:V4F_64 2 "general_operand")))] + "TARGET_MMX_WITH_SSE && TARGET_SSE4_1" +{ + bool ok = ix86_expand_int_vcond (operands); + gcc_assert (ok); + DONE; +}) + +(define_expand "vcond_mask_v4hi" + [(set (match_operand:V4F_64 0 "register_operand") + (vec_merge:V4F_64 + (match_operand:V4F_64 1 "register_operand") + (match_operand:V4F_64 2 "register_operand") + (match_operand:V4HI 3 "register_operand")))] + "TARGET_MMX_WITH_SSE && TARGET_SSE4_1" +{ + ix86_expand_sse_movcc (operands[0], operands[3], + operands[1], operands[2]); + DONE; +}) + +(define_expand "vcond_mask_qi" + [(set (match_operand:V4FI_64 0 "register_operand") + (vec_merge:V4FI_64 + (match_operand:V4FI_64 1 "register_operand") + (match_operand:V4FI_64 2 "register_operand") + (match_operand:QI 3 "register_operand")))] + "TARGET_MMX_WITH_SSE && TARGET_AVX512BW && TARGET_AVX512VL" +{ + rtx op0 = gen_reg_rtx (mode); + operands[1] = lowpart_subreg (mode, operands[1], mode); + operands[2] = lowpart_subreg (mode, operands[2], mode); + emit_insn (gen_vcond_mask_qi (op0, operands[1], + operands[2], operands[3])); + emit_move_insn (operands[0], + lowpart_subreg (mode, op0, mode)); + DONE; +}) + +(define_expand "vec_cmpv2hfqi" + [(set (match_operand:QI 0 "register_operand") + (match_operator:QI 1 "" + [(match_operand:V2HF 2 "nonimmediate_operand") + (match_operand:V2HF 3 "nonimmediate_operand")]))] + "TARGET_AVX512FP16 && TARGET_AVX512VL + && ix86_partial_vec_fp_math" +{ + rtx ops[4]; + ops[3] = gen_reg_rtx (V8HFmode); + ops[2] = gen_reg_rtx (V8HFmode); + + emit_insn (gen_movd_v2hf_to_sse (ops[3], operands[3])); + emit_insn (gen_movd_v2hf_to_sse (ops[2], operands[2])); + emit_insn (gen_vec_cmpv8hfqi (operands[0], operands[1], ops[2], ops[3])); + DONE; +}) + +(define_expand "vcondv2hf" + [(set (match_operand:V2FI_32 0 "register_operand") + (if_then_else:V2FI_32 + (match_operator 3 "" + [(match_operand:V2HF 4 "nonimmediate_operand") + (match_operand:V2HF 5 "nonimmediate_operand")]) + (match_operand:V2FI_32 1 "general_operand") + (match_operand:V2FI_32 2 "general_operand")))] + "TARGET_AVX512FP16 && TARGET_AVX512VL + && ix86_partial_vec_fp_math" +{ + rtx ops[6]; + ops[5] = gen_reg_rtx (V8HFmode); + ops[4] = gen_reg_rtx (V8HFmode); + ops[0] = gen_reg_rtx (mode); + ops[1] = lowpart_subreg (mode, + force_reg (mode, operands[1]), + mode); + ops[2] = lowpart_subreg (mode, + force_reg (mode, operands[2]), + mode); + ops[3] = operands[3]; + emit_insn (gen_movd_v2hf_to_sse (ops[4], operands[4])); + emit_insn (gen_movd_v2hf_to_sse (ops[5], operands[5])); + bool ok = ix86_expand_fp_vcond (ops); + gcc_assert (ok); + + emit_move_insn (operands[0], lowpart_subreg (mode, ops[0], + mode)); + DONE; +}) + +(define_expand "vcondv2hi" + [(set (match_operand:V2F_32 0 "register_operand") + (if_then_else:V2F_32 + (match_operator 3 "" + [(match_operand:V2HI 4 "nonimmediate_operand") + (match_operand:V2HI 5 "nonimmediate_operand")]) + (match_operand:V2F_32 1 "general_operand") + (match_operand:V2F_32 2 "general_operand")))] + "TARGET_SSE4_1" +{ + bool ok = ix86_expand_int_vcond (operands); + gcc_assert (ok); + DONE; +}) + +(define_expand "vconduv2hi" + [(set (match_operand:V2F_32 0 "register_operand") + (if_then_else:V2F_32 + (match_operator 3 "" + [(match_operand:V2HI 4 "nonimmediate_operand") + (match_operand:V2HI 5 "nonimmediate_operand")]) + (match_operand:V2F_32 1 "general_operand") + (match_operand:V2F_32 2 "general_operand")))] + "TARGET_SSE4_1" +{ + bool ok = ix86_expand_int_vcond (operands); + gcc_assert (ok); + DONE; +}) + +(define_expand "vcond_mask_v2hi" + [(set (match_operand:V2F_32 0 "register_operand") + (vec_merge:V2F_32 + (match_operand:V2F_32 1 "register_operand") + (match_operand:V2F_32 2 "register_operand") + (match_operand:V2HI 3 "register_operand")))] + "TARGET_SSE4_1" +{ + ix86_expand_sse_movcc (operands[0], operands[3], + operands[1], operands[2]); + DONE; +}) + +(define_expand "vcond_mask_qi" + [(set (match_operand:V2FI_32 0 "register_operand") + (vec_merge:V2FI_32 + (match_operand:V2FI_32 1 "register_operand") + (match_operand:V2FI_32 2 "register_operand") + (match_operand:QI 3 "register_operand")))] + "TARGET_AVX512BW && TARGET_AVX512VL" +{ + rtx op0 = gen_reg_rtx (mode); + operands[1] = lowpart_subreg (mode, operands[1], mode); + operands[2] = lowpart_subreg (mode, operands[2], mode); + emit_insn (gen_vcond_mask_qi (op0, operands[1], + operands[2], operands[3])); + emit_move_insn (operands[0], + lowpart_subreg (mode, op0, mode)); + DONE; +}) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Parallel half-precision floating point rounding operations. diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index c988935d4df..e2a7cbeb722 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -4644,29 +4644,14 @@ (define_expand "vcond" DONE; }) -(define_expand "vcond" - [(set (match_operand:VHF_AVX512VL 0 "register_operand") - (if_then_else:VHF_AVX512VL - (match_operator 3 "" - [(match_operand:VHF_AVX512VL 4 "vector_operand") - (match_operand:VHF_AVX512VL 5 "vector_operand")]) - (match_operand:VHF_AVX512VL 1 "general_operand") - (match_operand:VHF_AVX512VL 2 "general_operand")))] - "TARGET_AVX512FP16" -{ - bool ok = ix86_expand_fp_vcond (operands); - gcc_assert (ok); - DONE; -}) - -(define_expand "vcond" - [(set (match_operand: 0 "register_operand") - (if_then_else: +(define_expand "vcond" + [(set (match_operand:VI2HFBF_AVX512VL 0 "register_operand") + (if_then_else:VI2HFBF_AVX512VL (match_operator 3 "" [(match_operand:VHF_AVX512VL 4 "vector_operand") (match_operand:VHF_AVX512VL 5 "vector_operand")]) - (match_operand: 1 "general_operand") - (match_operand: 2 "general_operand")))] + (match_operand:VI2HFBF_AVX512VL 1 "general_operand") + (match_operand:VI2HFBF_AVX512VL 2 "general_operand")))] "TARGET_AVX512FP16" { bool ok = ix86_expand_fp_vcond (operands); diff --git a/gcc/testsuite/g++.target/i386/part-vect-vcondhf.C b/gcc/testsuite/g++.target/i386/part-vect-vcondhf.C new file mode 100644 index 00000000000..8bf01b7cb4a --- /dev/null +++ b/gcc/testsuite/g++.target/i386/part-vect-vcondhf.C @@ -0,0 +1,34 @@ +/* PR target/103861 */ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512fp16 -mavx512vl" } */ +/* { dg-final { scan-assembler-times "vpcmpeqw" 2 } } */ +/* { dg-final { scan-assembler-times "vpcmpgtw" 2 } } */ +/* { dg-final { scan-assembler-times "vcmpph" 4 } } */ +/* { dg-final { scan-assembler-times "vpblendvb" 4 } } */ +typedef unsigned short __attribute__((__vector_size__ (4))) __v2hu; +typedef short __attribute__((__vector_size__ (4))) __v2hi; + +typedef unsigned short __attribute__((__vector_size__ (8))) __v4hu; +typedef short __attribute__((__vector_size__ (8))) __v4hi; + +typedef _Float16 __attribute__((__vector_size__ (4))) __v2hf; +typedef _Float16 __attribute__((__vector_size__ (8))) __v4hf; + + +__v2hu au, bu; +__v2hi as, bs; +__v2hf af, bf; + +__v4hu cu, du; +__v4hi cs, ds; +__v4hf cf, df; + +__v2hf auf (__v2hu a, __v2hu b) { return (a > b) ? af : bf; } +__v2hf asf (__v2hi a, __v2hi b) { return (a > b) ? af : bf; } +__v2hu afu (__v2hf a, __v2hf b) { return (a > b) ? au : bu; } +__v2hi afs (__v2hf a, __v2hf b) { return (a > b) ? as : bs; } + +__v4hf cuf (__v4hu c, __v4hu d) { return (c > d) ? cf : df; } +__v4hf csf (__v4hi c, __v4hi d) { return (c > d) ? cf : df; } +__v4hu cfu (__v4hf c, __v4hf d) { return (c > d) ? cu : du; } +__v4hi cfs (__v4hf c, __v4hf d) { return (c > d) ? cs : ds; } diff --git a/gcc/testsuite/gcc.target/i386/part-vect-vec_cmphf.c b/gcc/testsuite/gcc.target/i386/part-vect-vec_cmphf.c new file mode 100644 index 00000000000..ee8659395eb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/part-vect-vec_cmphf.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512fp16 -mavx512vl" } */ +/* { dg-final { scan-assembler-times "vcmpph" 10 } } */ + +typedef _Float16 __attribute__((__vector_size__ (4))) v2hf; +typedef _Float16 __attribute__((__vector_size__ (8))) v4hf; + + +#define VCMPMN(type, op, name) \ +type \ +__attribute__ ((noinline, noclone)) \ +vec_cmp_##type##type##name (type a, type b) \ +{ \ + return a op b; \ +} + +VCMPMN (v4hf, <, lt) +VCMPMN (v2hf, <, lt) +VCMPMN (v4hf, <=, le) +VCMPMN (v2hf, <=, le) +VCMPMN (v4hf, >, gt) +VCMPMN (v2hf, >, gt) +VCMPMN (v4hf, >=, ge) +VCMPMN (v2hf, >=, ge) +VCMPMN (v4hf, ==, eq) +VCMPMN (v2hf, ==, eq)