Message ID | Z83-CJmVXhUKHXH1@sawtooth |
---|---|
State | Committed |
Commit | f4f7216c56fe2f67c72db5b7c4afa220725f3ed1 |
Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 628473858CD1 for <patchwork@sourceware.org>; Sun, 9 Mar 2025 20:46:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 628473858CD1 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=XeXymZ5W X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by sourceware.org (Postfix) with ESMTPS id BC0E93858D1E for <gcc-patches@gcc.gnu.org>; Sun, 9 Mar 2025 20:46:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC0E93858D1E 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 BC0E93858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::82e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741553162; cv=none; b=F7XvhbkKxI7N5QC1N0Ht+ABahyaE5KcPTkfVU+NnjctjE8jJO5T4HilhejbdJjfDhAT7tZb2Sc+/2HOT6S4QpvwhKVXmqcNZ2l4bXxyr96Kjc+fzCeIbqUV5W06zJLjsb1l78keXJMJwjb3pvFzVLQxaX1J7xxvA5bApKhdwHQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741553162; c=relaxed/simple; bh=6hXgX9z2+d5xA6qOZ0eI2VMIZ1KKIt5qa6H4T5WezNY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=H/beDGx+OBjEuJN2UHUAOM1K9Ii4HYdTSBy0W25ij7CQsxkBbgwTr/vgPM56du13pVDXqkyivG0mgntlrPZfXTTPGMEpczKkVGOrzCdOQLW1xnkzpuwFBFYScYrCldjywIjaJW7scRjM54rLKqLXGq6OKRtaP5kAmbisQAfbKt0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC0E93858D1E Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-46c8474d8daso27501991cf.3 for <gcc-patches@gcc.gnu.org>; Sun, 09 Mar 2025 13:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741553162; x=1742157962; darn=gcc.gnu.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=5xfi0WXEnHszNRJSpn8t+6B5ZtTVO4R7RRIoyvkrt/4=; b=XeXymZ5W3lt0oWCp/n2HFPIOetfmUjGLRR+qYqbd169G0+AYS7TkP0Dea1TsXrIwLd fOD6rXIN4WNMNtibQfr7fqhVd0Q2tRArx5Z5F/bqdB8Yxn6n3yYXwdgNTcW4kFL/Sjnm MgQlDyi/W544mHDUJ60qBQ6528Il7emir+eW8KobItAGyBNVGiRp7z/tEmLRtDMZG/3H gTJZTkXtljHA9B91PcboYkoAcn6oPnuXP0xaI71nGTAPWBQfHQOU/J6N6yl+qxeqkYbx hJrwXtL967eMXk6IPRHF9B8We8Zqwm5YVNEH3OBNvpPBk4FBSArabGX8w8zKALhc6VjX 5YdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741553162; x=1742157962; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5xfi0WXEnHszNRJSpn8t+6B5ZtTVO4R7RRIoyvkrt/4=; b=pMTTMNsXADt/E05KNHDM1DwlAK+0cFXnLdQwDZWgXaVSsZJmAu3qho6YiGBeM+m+sE NUzoqmAXGcGN8uN78DOkD9YlhYmzB+26a/4OBaHi8mDfnyQ/nAtZaKquIGkjc6f0xTIz i5PEIAN0N17objToVoSNETk6wCu2qsAN1AJa1QlwyDnpIw6SS4hAYCsyo7d713kfdFXy bsXrnrzoXk5ua6xl69ehArRNjmOxg8loShLsjYrCW1+XYO32xhDKTnzfZ98iZ8rwobgD VrPoUwSmntRL23Nsmq8uqLwYlk6UWYmI4eOMzu3O04yN2igTqQxFKIU7itk0D55Ywl4k JXMg== X-Gm-Message-State: AOJu0Yz2gV9FQLRDtEmHpyLneyuuMLW4yVHKwDDiatsSgFZ5Do529+wM MGARROVQXK+E+0S1Of8Vz7/fNBFeK0P/Hw9VhPr8MIpGqtTOgxE06SaqEg4x X-Gm-Gg: ASbGncuqQccFJXR66pEfhxIlK6VSmmJTwU0r3wBtSzudmbhignuMFHmaKHTER75l9W2 GOcfYJ2C7QtR2sT+PwkMvDCmiL8TGxbXzTEZguef9MuPW4Tu3aPk/FzO6yB8sL3p3X0nzu8Ds/g WokYKkHmRQ7cpKgOX0zX6ZM/vM2GRjmwNg48oYaKHAxjQePXABZA32RlysZFpTAcmbp7MiBNXYz KOuwERKFazVzGhmJ12/m7t+x5lx9zegOomUxQjBG+fQJN3OqynFxw6vDWwSpXGG52jqyxWake4B Wy+vfrMJkUZFu6hfVLEfg3pnuT4sknVa37NoS1NZ36g55cd1qjWnKN+5YZAuqDAwFyXp9Ui2q5t +9TD9IUpbYbt3EBkb1OP2 X-Google-Smtp-Source: AGHT+IGSUMxltjVcRdtFJfQjME5po1GqGE2pxa6ZAGmo30edReiBjZXGLozYAWgkN6TzoRbQmotMww== X-Received: by 2002:ac8:5dd2:0:b0:471:f185:cdcf with SMTP id d75a77b69052e-47618af3525mr127035481cf.51.1741553161777; Sun, 09 Mar 2025 13:46:01 -0700 (PDT) Received: from sawtooth (pool-96-237-251-112.bstnma.fios.verizon.net. [96.237.251.112]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4767a003c0bsm13048731cf.21.2025.03.09.13.46.01 for <gcc-patches@gcc.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Mar 2025 13:46:01 -0700 (PDT) Date: Sun, 9 Mar 2025 16:46:00 -0400 From: Ayan Shafqat <ayan.x.shafqat@gmail.com> To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] aarch64: Add FMA and FMAF intrinsics and tests Message-ID: <Z83-CJmVXhUKHXH1@sawtooth> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_SBL_A 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
Series |
[1/2] aarch64: Add FMA and FMAF intrinsics and tests
|
|
Commit Message
Ayan Shafqat
March 9, 2025, 8:46 p.m. UTC
This patch introduces inline definitions for the __fma and __fmaf
functions in arm_acle.h for AArch64 targets. These definitions rely on
__builtin_fma and __builtin_fmaf to ensure proper inlining and to meet
the ACLE requirements [1].
The patch has been tested locally using a crosstool-NG sysroot for
AArch64, confirming that the generated code uses the expected fused
multiply-accumulate instructions (fmadd).
[1] https://arm-software.github.io/acle/main/acle.html#fused-multiply-accumulate-fma
Signed-off-by: Ayan Shafqat <ayan.x.shafqat@gmail.com>
---
gcc/config/aarch64/arm_acle.h | 14 ++++++++++++++
.../gcc.target/aarch64/acle/acle_fma.c | 17 +++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c
Comments
Hi Ayan, > On 9 Mar 2025, at 21:46, Ayan Shafqat <ayan.x.shafqat@gmail.com> wrote: > > This patch introduces inline definitions for the __fma and __fmaf > functions in arm_acle.h for AArch64 targets. These definitions rely on > __builtin_fma and __builtin_fmaf to ensure proper inlining and to meet > the ACLE requirements [1]. > > The patch has been tested locally using a crosstool-NG sysroot for > AArch64, confirming that the generated code uses the expected fused > multiply-accumulate instructions (fmadd). > This looks ok to me. GCC is currently in a regression fixing stage so normally such a change would wait until stage 1 reopens. But this looks like a pretty safe change so I’m not against taking it now. Do you need someone to commit this for you? Thanks, Kyrill > [1] https://arm-software.github.io/acle/main/acle.html#fused-multiply-accumulate-fma > > Signed-off-by: Ayan Shafqat <ayan.x.shafqat@gmail.com> > > --- > gcc/config/aarch64/arm_acle.h | 14 ++++++++++++++ > .../gcc.target/aarch64/acle/acle_fma.c | 17 +++++++++++++++++ > 2 files changed, 31 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c > > diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h > index 7976c117daf..d9e2401ea9f 100644 > --- a/gcc/config/aarch64/arm_acle.h > +++ b/gcc/config/aarch64/arm_acle.h > @@ -129,6 +129,20 @@ __jcvt (double __a) > > #pragma GCC pop_options > > +__extension__ extern __inline double > +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > +__fma (double __x, double __y, double __z) > +{ > + return __builtin_fma (__x, __y, __z); > +} > + > +__extension__ extern __inline float > +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) > +__fmaf (float __x, float __y, float __z) > +{ > + return __builtin_fmaf (__x, __y, __z); > +} > + > #pragma GCC push_options > #pragma GCC target ("+nothing+frintts") > __extension__ extern __inline float > diff --git a/gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c b/gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c > new file mode 100644 > index 00000000000..9363a75b593 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c > @@ -0,0 +1,17 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +#include "arm_acle.h" > + > +double test_acle_fma (double x, double y, double z) > +{ > + return __fma (x, y, z); > +} > + > +float test_acle_fmaf (float x, float y, float z) > +{ > + return __fmaf (x, y, z); > +} > + > +/* { dg-final { scan-assembler-times "fmadd\td\[0-9\]" 1 } } */ > +/* { dg-final { scan-assembler-times "fmadd\ts\[0-9\]" 1 } } */ > -- > 2.43.0 >
Hello Kyrylo, On Tue, Mar 11, 2025 at 08:55:46AM +0000, Kyrylo Tkachov wrote: > This looks ok to me. > GCC is currently in a regression fixing stage so normally such a change would wait until stage 1 reopens. > But this looks like a pretty safe change so I’m not against taking it now. > Do you need someone to commit this for you? Thank you very much for reviewing this patch! I do not have commit access to GCC, so I would greatly appreciate it if you can commit this patch on my behalf. Please let me know if you need anything else. Best regards, Ayan
Hi Ayan, > On 11 Mar 2025, at 14:53, Ayan Shafqat <ayan.x.shafqat@gmail.com> wrote: > > Hello Kyrylo, > > On Tue, Mar 11, 2025 at 08:55:46AM +0000, Kyrylo Tkachov wrote: >> This looks ok to me. >> GCC is currently in a regression fixing stage so normally such a change would wait until stage 1 reopens. >> But this looks like a pretty safe change so I’m not against taking it now. >> Do you need someone to commit this for you? > > Thank you very much for reviewing this patch! I do not have commit > access to GCC, so I would greatly appreciate it if you can commit this > patch on my behalf. Please let me know if you need anything else. > I forgot during the review, but a patch needs a ChangeLog entry. Could you provide one please to add to the commit log? Thanks, Kyrill > Best regards, > Ayan
On Thu, Mar 13, 2025 at 08:31:24AM +0000, Kyrylo Tkachov wrote: > > I forgot during the review, but a patch needs a ChangeLog entry. > Could you provide one please to add to the commit log? > I have submitted the patch again in the mailing list: https://gcc.gnu.org/pipermail/gcc-patches/2025-March/677588.html Let me know if you need anything else. Thanks in advance, Ayan
diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h index 7976c117daf..d9e2401ea9f 100644 --- a/gcc/config/aarch64/arm_acle.h +++ b/gcc/config/aarch64/arm_acle.h @@ -129,6 +129,20 @@ __jcvt (double __a) #pragma GCC pop_options +__extension__ extern __inline double +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +__fma (double __x, double __y, double __z) +{ + return __builtin_fma (__x, __y, __z); +} + +__extension__ extern __inline float +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +__fmaf (float __x, float __y, float __z) +{ + return __builtin_fmaf (__x, __y, __z); +} + #pragma GCC push_options #pragma GCC target ("+nothing+frintts") __extension__ extern __inline float diff --git a/gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c b/gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c new file mode 100644 index 00000000000..9363a75b593 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/acle_fma.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include "arm_acle.h" + +double test_acle_fma (double x, double y, double z) +{ + return __fma (x, y, z); +} + +float test_acle_fmaf (float x, float y, float z) +{ + return __fmaf (x, y, z); +} + +/* { dg-final { scan-assembler-times "fmadd\td\[0-9\]" 1 } } */ +/* { dg-final { scan-assembler-times "fmadd\ts\[0-9\]" 1 } } */