From patchwork Thu Sep 12 01:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Levy Hsu X-Patchwork-Id: 1984270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=levyhsu.com header.i=@levyhsu.com header.a=rsa-sha256 header.s=default header.b=UMC1VPl9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X40s31y1Vz1y25 for ; Thu, 12 Sep 2024 11:55:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77698385842C for ; Thu, 12 Sep 2024 01:55:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out28-66.mail.aliyun.com (out28-66.mail.aliyun.com [115.124.28.66]) by sourceware.org (Postfix) with ESMTPS id EB1CF3858C52 for ; Thu, 12 Sep 2024 01:55:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB1CF3858C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=levyhsu.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=levyhsu.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EB1CF3858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=115.124.28.66 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726106124; cv=none; b=dtoztsX4fKRIvbHiP6jvSPC5JSd5533s7YJqN21AtXBn6gcNui4K/W/pSwAv4nBctzOZY5VJc1RhCYa969O8Di65XsO8li2o3pws0oJPthZaWHp8IWLG+qfFDvEaLn+kVPLMEncKLCcj/gvQ8LfcWTQ0fBY7i7dJMsR/AllQPhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726106124; c=relaxed/simple; bh=v8+9NRVyVKhL2xiEh9EEEgt3QFkkKyz2Cfkba0JkLLU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=yBGLuZ+Ew51NpmkwpJ5BpQoJo5/FgR+MaQrxSetHf+1blZKF+t+SvQslq07MoBLjmmha3/UhJbppKThOkBAFBe2dlAWjeI/PD6m/yqRcIgo9ngNHQXOSwkpdohLmrNIQfMTLtAPCeeR94mU+YgoBPscyEXdMy36CumjlNo5yPWE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=levyhsu.com; s=default; t=1726106103; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=pwa/ZWpnIAh8F21Pj9hr5ndbw28Wb7CbXBvXmFHHnsU=; b=UMC1VPl9OkaXVhkrS2ErUdT6D5Ouo2vA4IJGHyy0aSi/giS1MU5QbLuvS+gn1k4VIBDW4OgdovmrORnc74YBv5UkLFcV/2eNAsdHo8w49HwbfK6ReJoXLW12uzGhx3hZKc/ENeKY/z6QbwGPii0oSQktJST5+5vLXPCxgHYvQ1tZV+fYaNhzH4v+JlLW3xc0v90runAHiOpXPocGBR+0GduJFSBHtH03gs/AvySqQdOMI6QthyJfPIS/I41CxndRJQTfIJlsVRDivLxRrjFcaRDVbwuISzLCBvnzpzeIQufX4nLV6HIC8xJgNfmdcB+CDaS5R0R+uw91/WHJHeYoBQ== Received: from ip-10-0-154-97.us-west-2.compute.internal(mailfrom:admin@levyhsu.com fp:SMTPD_---.ZGthuJ._1726106095) by smtp.aliyun-inc.com; Thu, 12 Sep 2024 09:54:58 +0800 From: Levy Hsu To: gcc-patches@gcc.gnu.org Cc: admin@levyhsu.com, liwei.xu@intel.com, crazylht@gmail.com, ubizjak@gmail.com Subject: [PATCH v2] Enable V2BF/V4BF vec_cmp with AVX10.2 vcmppbf16 Date: Thu, 12 Sep 2024 01:51:33 +0000 Message-ID: <20240912015453.53318-1-admin@levyhsu.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, TXREP, T_SPF_PERMERROR, UNPARSEABLE_RELAY 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~incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? gcc/ChangeLog: * config/i386/i386.cc (ix86_get_mask_mode): Enable BFmode for targetm.vectorize.get_mask_mode with AVX10.2. * config/i386/mmx.md (vec_cmpqi): Implement vec_cmpv2bfqi and vec_cmpv4bfqi. gcc/testsuite/ChangeLog: * gcc.target/i386/part-vect-vec_cmpbf.c: New test. --- gcc/config/i386/i386.cc | 3 ++- gcc/config/i386/mmx.md | 17 ++++++++++++ .../gcc.target/i386/part-vect-vec_cmpbf.c | 26 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 45320124b91..7dbae1d72e3 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -24682,7 +24682,8 @@ ix86_get_mask_mode (machine_mode data_mode) /* AVX512FP16 only supports vector comparison to kmask for _Float16. */ || (TARGET_AVX512VL && TARGET_AVX512FP16 - && GET_MODE_INNER (data_mode) == E_HFmode)) + && GET_MODE_INNER (data_mode) == E_HFmode) + || (TARGET_AVX10_2_256 && GET_MODE_INNER (data_mode) == E_BFmode)) { if (elem_size == 4 || elem_size == 8 diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index 4bc191b874b..95d9356694a 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -2290,6 +2290,23 @@ DONE; }) +;;This instruction does not generate floating point exceptions +(define_expand "vec_cmpqi" + [(set (match_operand:QI 0 "register_operand") + (match_operator:QI 1 "" + [(match_operand:VBF_32_64 2 "register_operand") + (match_operand:VBF_32_64 3 "nonimmediate_operand")]))] + "TARGET_AVX10_2_256" +{ + rtx op2 = lowpart_subreg (V8BFmode, + force_reg (mode, operands[2]), mode); + rtx op3 = lowpart_subreg (V8BFmode, + force_reg (mode, operands[3]), mode); + + emit_insn (gen_vec_cmpv8bfqi (operands[0], operands[1], op2, op3)); + DONE; +}) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Parallel half-precision floating point rounding operations. diff --git a/gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c b/gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c new file mode 100644 index 00000000000..0bb720b6432 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/part-vect-vec_cmpbf.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx10.2" } */ +/* { dg-final { scan-assembler-times "vcmppbf16" 10 } } */ + +typedef __bf16 __attribute__((__vector_size__ (4))) v2bf; +typedef __bf16 __attribute__((__vector_size__ (8))) v4bf; + + +#define VCMPMN(type, op, name) \ +type \ +__attribute__ ((noinline, noclone)) \ +vec_cmp_##type##type##name (type a, type b) \ +{ \ + return a op b; \ +} + +VCMPMN (v4bf, <, lt) +VCMPMN (v2bf, <, lt) +VCMPMN (v4bf, <=, le) +VCMPMN (v2bf, <=, le) +VCMPMN (v4bf, >, gt) +VCMPMN (v2bf, >, gt) +VCMPMN (v4bf, >=, ge) +VCMPMN (v2bf, >=, ge) +VCMPMN (v4bf, ==, eq) +VCMPMN (v2bf, ==, eq)