From patchwork Wed May 1 19:55:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1930352 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; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Eecbiix8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4VV7936tJJz1ymp for ; Thu, 2 May 2024 05:55:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23A473858C50 for ; Wed, 1 May 2024 19:55:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 9ADD93858D20 for ; Wed, 1 May 2024 19:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9ADD93858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9ADD93858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714593330; cv=none; b=PUnMje/KcrTM5LZhZH4fd2JvVUKZhziDTjNtm8B0zys96Hv7NQGKoPOd3kP41jwHgSvGr7TugaIYF4muaumHYfql8oO6CvcVLA72h1gEvcOr5eflkGaXEkcIvXvg+5h+WEviK8TTzSNhdswSwSN6WAQpFnzS3AqRL6iVv7lBGAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714593330; c=relaxed/simple; bh=hIJ9mBitcGyrJlA1xiv0mRjN8uu/vBfZFtXLLsOJXAs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=V++nm1z71mNrqVMASf+qwxUA0htWbX0F4UhLYuHN8QT/e2E5CJEGtq2cPs8zJGGsKqm5JEahe8kq8MQT7GWP/W39oHh3yEOHbrh4OijcON0rUAnOGX9vmipJMNnPBWKfjlv8+0nBNAAaZddZRY+x84zUxEvWIrFXna/WDyh4st0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e83a2a4f2cso47552015ad.1 for ; Wed, 01 May 2024 12:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714593327; x=1715198127; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=E4AP1QFd6W0YNC9+NnkOGqEwA9qlz0olmowbyXyIQaQ=; b=Eecbiix8RX1TFeMfkNwgP0X0JrBU0sLArdw6WNTV0krj6TQBMYKsI5LnM8hS1M8HSX Gd65l9/OugiWYd2fhm/oib2sVAkU686HVD17Z/jLjCRdh8r+YRTglVnCfr+n1nuJKaWk WrsUcseRrn/cX+jT7FE82oa4br/BCQDfHHNb9UwjRXeqTJ8onEwe/I6cgGBQmRj+xUo2 WWH7xCrgWsnxFqA/ak01q2dR58mY0W+mK3uO+wbtgrpsUaUj9ak4fD2Nz9eyD35jLJNf 2HxQ3KsUbrjPLMFtIEIw30Pd2/+F1dsoZoNk7h//E7ZNRRE69gqxXJB1MPdQP/AOLvFi H+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714593327; x=1715198127; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E4AP1QFd6W0YNC9+NnkOGqEwA9qlz0olmowbyXyIQaQ=; b=DfmTvfQ+eK+aWi/tyqCp8ET0lAbzPBSF/YGvZjPmJT1jPO+w8FTvedk+44qWHsQtMy qKzEShsgGLXPpHtAyjq1xGLZ5ozntqeSb2WZ1rftu6nFyF7E0syTZgvBAHcti2oEWwi5 6Ifp6xU+o1J+eZfQyt7hvhAmsadUmU8o6EsnkkEJdtrBLsk5MsVn0TfAtdM1GoEvXH9d 19gXEJQGlFDAfyimnTLZ7wWtgmkLaIUmpNU0naMOcM+GY7chnl8VoYOpU4uQ5eBg9JFT F7qE5+x9kXrG55InZWeNWLg7p+J4K5nAGCSk9/scG8h6CGg7fLSnudNcWBXiZcpPXvLg 9TQA== X-Gm-Message-State: AOJu0YzH7yONwJijBG8AEArSpt3DYMzJC5xmRK8x5o/VQSwxlog2w+2p ySMtctGS8qjk9pjV+RVxnrH+YGy8wwE/j3+Inf9FxEhpezWte32nUUM7kw== X-Google-Smtp-Source: AGHT+IE10l4RHOV348u2oufheZSsFp+lMBhxyxHnZvpkV1MiYJRX0cnV9z2/0yHKlvfQiwF+vtmCwQ== X-Received: by 2002:a17:902:f68f:b0:1e3:dfdb:ac6b with SMTP id l15-20020a170902f68f00b001e3dfdbac6bmr3829748plg.4.1714593327269; Wed, 01 May 2024 12:55:27 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.168.158]) by smtp.gmail.com with ESMTPSA id x9-20020a170902a38900b001eb0dd08d96sm10387305pla.57.2024.05.01.12.55.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 12:55:27 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id D05EC740082 for ; Wed, 1 May 2024 12:55:25 -0700 (PDT) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: [PATCH] libgcc: Rename __trunchfbf2 to __extendhfbf2 Date: Wed, 1 May 2024 12:55:25 -0700 Message-ID: <20240501195525.599855-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Since bfloat16 has the same range as float32, _Float16 to bfloat16 conversion is an extension, not a truncation. Rename trunchfbf2.c to extendhfbf2.c to provide __extendhfbf2, instead of __trunchfbf2. Since _Float16 to bfloat16 conversion never worked from the day one, the same libgcc version of __trunchfbf2 is used with __extendhfbf2 so that this can be backported to release branches all the way where __trunchfbf2 was added. gcc/testsuite/ PR libgcc/114907 * gcc.dg/pr114907-1.c: New test. * gcc.dg/pr114907-2.c: Likewise. libgcc/ PR libgcc/114907 * config/aarch64/libgcc-softfp.ver (__trunchfbf2): Renamed to ... (__extendhfbf2): This. * config/aarch64/t-softfp (softfp_extensions): Add hfbf. (softfp_truncations): Remove hfbf. * config/i386/libgcc-darwin.ver (__trunchfbf2): Renamed to ... (__extendhfbf2): This. * config/i386/libgcc-glibc.ver (__trunchfbf2): Renamed to ... (__extendhfbf2): This. * config/i386/libgcc-sol2.ver (__trunchfbf2): Renamed to ... (__extendhfbf2): This. * config/i386/t-softfp (softfp_extensions): Add hfbf. (softfp_truncations): Remove hfbf. (CFLAGS-trunchfbf2.c): Renamed to ... (CFLAGS-extendhfbf2.c): This. * soft-fp/trunchfbf2.c: Renamed to ... * soft-fp/extendhfbf2.c: This. (__trunchfbf2): Renamed to ... (__extendhfbf2): This. --- gcc/testsuite/gcc.dg/pr114907-1.c | 21 +++++++++++++++++++ gcc/testsuite/gcc.dg/pr114907-2.c | 17 +++++++++++++++ libgcc/config/aarch64/libgcc-softfp.ver | 2 +- libgcc/config/aarch64/t-softfp | 4 ++-- libgcc/config/i386/libgcc-darwin.ver | 2 +- libgcc/config/i386/libgcc-glibc.ver | 2 +- libgcc/config/i386/libgcc-sol2.ver | 2 +- libgcc/config/i386/t-softfp | 6 +++--- .../soft-fp/{trunchfbf2.c => extendhfbf2.c} | 6 +++--- 9 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr114907-1.c create mode 100644 gcc/testsuite/gcc.dg/pr114907-2.c rename libgcc/soft-fp/{trunchfbf2.c => extendhfbf2.c} (94%) diff --git a/gcc/testsuite/gcc.dg/pr114907-1.c b/gcc/testsuite/gcc.dg/pr114907-1.c new file mode 100644 index 00000000000..9f6219d5e88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114907-1.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ +/* { dg-add-options bfloat16 } */ +/* { dg-require-effective-target bfloat16_runtime } */ + +__bf16 bfa, bfb, bfc, bfd, bfe, bff; +_Float16 f16a, f16b; +float f32a, f32b; +double da, db; + +int +main (void) +{ + bfa = f16a; + f16b = bfb; + bfc = f32a; + f32b = bfd; + bfe = da; + db = bff; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr114907-2.c b/gcc/testsuite/gcc.dg/pr114907-2.c new file mode 100644 index 00000000000..41cc88f0652 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114907-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-O0" } */ +/* { dg-add-options bfloat16 } */ +/* { dg-add-options __float128 } */ +/* { dg-require-effective-target bfloat16_runtime } */ +/* { dg-require-effective-target __float128 } */ + +__bf16 bfa, bfb; +__float128 fa, fb; + +int +main (void) +{ + bfa = fa; + fb = bfb; + return 0; +} diff --git a/libgcc/config/aarch64/libgcc-softfp.ver b/libgcc/config/aarch64/libgcc-softfp.ver index 9ba857036ab..d6e427cbf7e 100644 --- a/libgcc/config/aarch64/libgcc-softfp.ver +++ b/libgcc/config/aarch64/libgcc-softfp.ver @@ -30,6 +30,7 @@ GCC_11.0 { %inherit GCC_13.0.0 GCC_11.0.0 GCC_13.0.0 { __extendbfsf2 + __extendhfbf2 __floatdibf __floattibf __floatundibf @@ -37,7 +38,6 @@ GCC_13.0.0 { __truncdfbf2 __truncsfbf2 __trunctfbf2 - __trunchfbf2 } %inherit GCC_14.0.0 GCC_13.0.0 diff --git a/libgcc/config/aarch64/t-softfp b/libgcc/config/aarch64/t-softfp index 80e7e77a545..5c7e6dbc5b5 100644 --- a/libgcc/config/aarch64/t-softfp +++ b/libgcc/config/aarch64/t-softfp @@ -1,7 +1,7 @@ softfp_float_modes := tf softfp_int_modes := si di ti -softfp_extensions := sftf dftf hftf bfsf -softfp_truncations := tfsf tfdf tfhf tfbf dfbf sfbf hfbf +softfp_extensions := sftf dftf hftf bfsf hfbf +softfp_truncations := tfsf tfdf tfhf tfbf dfbf sfbf softfp_exclude_libgcc2 := n softfp_extras += fixhfti fixunshfti floattihf floatuntihf \ floatdibf floatundibf floattibf floatuntibf \ diff --git a/libgcc/config/i386/libgcc-darwin.ver b/libgcc/config/i386/libgcc-darwin.ver index 06560d6b47f..1e7efb828ed 100644 --- a/libgcc/config/i386/libgcc-darwin.ver +++ b/libgcc/config/i386/libgcc-darwin.ver @@ -29,13 +29,13 @@ GCC_12.0.0 { GCC_14.0.0 { # Added to GCC_13.0.0 in i386/libgcc-glibc.ver. __extendbfsf2 + __extendhfbf2 __floattibf __floatuntibf __truncdfbf2 __truncsfbf2 __trunctfbf2 __truncxfbf2 - __trunchfbf2 # Added to GCC_14.0.0 in i386/libgcc-glibc.ver. __fixxfbitint __fixtfbitint diff --git a/libgcc/config/i386/libgcc-glibc.ver b/libgcc/config/i386/libgcc-glibc.ver index 5b360ac1249..451f1b1c57f 100644 --- a/libgcc/config/i386/libgcc-glibc.ver +++ b/libgcc/config/i386/libgcc-glibc.ver @@ -218,13 +218,13 @@ GCC_12.0.0 { %inherit GCC_13.0.0 GCC_12.0.0 GCC_13.0.0 { __extendbfsf2 + __extendhfbf2 __floattibf __floatuntibf __truncdfbf2 __truncsfbf2 __trunctfbf2 __truncxfbf2 - __trunchfbf2 } %inherit GCC_14.0.0 GCC_13.0.0 diff --git a/libgcc/config/i386/libgcc-sol2.ver b/libgcc/config/i386/libgcc-sol2.ver index 77570b634a3..59dcfeca674 100644 --- a/libgcc/config/i386/libgcc-sol2.ver +++ b/libgcc/config/i386/libgcc-sol2.ver @@ -136,13 +136,13 @@ GCC_14.0.0 { __truncxfhf2 # Added to GCC_13.0.0 in i386/libgcc-glibc.ver. __extendbfsf2 + __extendhfbf2 __floattibf __floatuntibf __truncdfbf2 __truncsfbf2 __trunctfbf2 __truncxfbf2 - __trunchfbf2 # Added to GCC_14.0.0 in i386/libgcc-glibc.ver. __fixxfbitint __fixtfbitint diff --git a/libgcc/config/i386/t-softfp b/libgcc/config/i386/t-softfp index 222698d9efd..07d9bb0aeca 100644 --- a/libgcc/config/i386/t-softfp +++ b/libgcc/config/i386/t-softfp @@ -6,9 +6,9 @@ LIB2FUNCS_EXCLUDE += $(libgcc2-hf-functions) libgcc2-hf-extras = $(addsuffix .c, $(libgcc2-hf-functions)) LIB2ADD += $(addprefix $(srcdir)/config/i386/, $(libgcc2-hf-extras)) -softfp_extensions := hfsf hfdf hftf hfxf sfdf sftf dftf xftf bfsf +softfp_extensions := hfsf hfdf hftf hfxf sfdf sftf dftf xftf bfsf hfbf softfp_truncations := tfhf xfhf dfhf sfhf tfsf dfsf tfdf tfxf \ - tfbf xfbf dfbf sfbf hfbf + tfbf xfbf dfbf sfbf softfp_extras += eqhf2 fixxfbitint $(foreach m,hf bf xf,floatbitint$(m)) @@ -17,6 +17,7 @@ CFLAGS-extendhfdf2.c += -msse2 CFLAGS-extendhftf2.c += -msse2 CFLAGS-extendhfxf2.c += -msse2 CFLAGS-extendbfsf2.c += -msse2 +CFLAGS-extendhfbf2.c += -msse2 CFLAGS-truncsfhf2.c += -msse2 CFLAGS-truncdfhf2.c += -msse2 @@ -26,7 +27,6 @@ CFLAGS-truncsfbf2.c += -msse2 CFLAGS-truncdfbf2.c += -msse2 CFLAGS-truncxfbf2.c += -msse2 CFLAGS-trunctfbf2.c += -msse2 -CFLAGS-trunchfbf2.c += -msse2 CFLAGS-floatbitintbf.c += -msse2 CFLAGS-floatbitinthf.c += -msse2 diff --git a/libgcc/soft-fp/trunchfbf2.c b/libgcc/soft-fp/extendhfbf2.c similarity index 94% rename from libgcc/soft-fp/trunchfbf2.c rename to libgcc/soft-fp/extendhfbf2.c index f3d650123ef..3443948da3f 100644 --- a/libgcc/soft-fp/trunchfbf2.c +++ b/libgcc/soft-fp/extendhfbf2.c @@ -1,6 +1,6 @@ /* Software floating-point emulation. - Truncate IEEE half into bfloat16. - Copyright (C) 2022 Free Software Foundation, Inc. + Extend IEEE half into bfloat16. + Copyright (C) 2022-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ truncate to BFtype. */ BFtype -__trunchfbf2 (HFtype a) +__extendhfbf2 (HFtype a) { FP_DECL_EX; FP_DECL_H (A);