From 7e95f738620dc805868d198f980e1bdd53e27a2d Mon Sep 17 00:00:00 2001
From: Andreas Klebinger <klebinger.andreas@gmx.at>
Date: Thu, 11 Jan 2024 15:10:09 +0100
Subject: [PATCH] Aarch64: Enable -mfma by default.

Fixes #24311
---
 compiler/GHC/Driver/DynFlags.hs | 3 ++-
 docs/users_guide/using.rst      | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/compiler/GHC/Driver/DynFlags.hs b/compiler/GHC/Driver/DynFlags.hs
index 63f2ec15875b..55a11df38b87 100644
--- a/compiler/GHC/Driver/DynFlags.hs
+++ b/compiler/GHC/Driver/DynFlags.hs
@@ -699,7 +699,8 @@ defaultDynFlags mySettings =
         avx512er = False,
         avx512f = False,
         avx512pf = False,
-        fma = False,
+        -- Use FMA by default on AArch64
+        fma = (platformArch . sTargetPlatform $ mySettings) == ArchAArch64,
 
         maxInlineAllocSize = 128,
         maxInlineMemcpyInsns = 32,
diff --git a/docs/users_guide/using.rst b/docs/users_guide/using.rst
index 10b793bd85af..0c9cb898d04f 100644
--- a/docs/users_guide/using.rst
+++ b/docs/users_guide/using.rst
@@ -1415,7 +1415,7 @@ messages and in GHCi:
 
     The structure of the output is described by a `JSON Schema <https://json-schema.org/>`_.
     The schema can be downloaded :download:`here <diagnostics-as-json-schema-1_0.json>`.
-    
+
 .. ghc-flag:: -fdiagnostics-color=⟨always|auto|never⟩
     :shortdesc: Use colors in error messages
     :type: dynamic
@@ -1761,6 +1761,8 @@ Some flags only make sense for particular target platforms.
     :type: dynamic
     :category: platform-options
 
+    :default: off by default, except for Aarch64 where it's on by default.
+
     :since: 9.8.1
 
     Use native FMA instructions to implement the fused multiply-add floating-point
-- 
GitLab