diff options
Diffstat (limited to 'compiler/GHC/Driver')
-rw-r--r-- | compiler/GHC/Driver/Config/StgToCmm.hs | 22 | ||||
-rw-r--r-- | compiler/GHC/Driver/Pipeline/Execute.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 11 |
3 files changed, 33 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Config/StgToCmm.hs b/compiler/GHC/Driver/Config/StgToCmm.hs index 283ece1d50..f738974c46 100644 --- a/compiler/GHC/Driver/Config/StgToCmm.hs +++ b/compiler/GHC/Driver/Config/StgToCmm.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiWayIf #-} + module GHC.Driver.Config.StgToCmm ( initStgToCmmConfig ) where @@ -6,6 +9,7 @@ import GHC.Prelude.Basic import GHC.StgToCmm.Config +import GHC.Cmm.MachOp ( FMASign(..)) import GHC.Driver.Backend import GHC.Driver.Session import GHC.Platform @@ -50,6 +54,24 @@ initStgToCmmConfig dflags mod = StgToCmmConfig , stgToCmmAllowQuotRemInstr = ncg && (x86ish || ppc) , stgToCmmAllowQuotRem2 = (ncg && (x86ish || ppc)) || llvm , stgToCmmAllowExtendedAddSubInstrs = (ncg && (x86ish || ppc)) || llvm + , stgToCmmAllowFMAInstr = + if + | not (isFmaEnabled dflags) + || not (ncg || llvm) + -- If we're not using the native code generator or LLVM, + -- fall back to the generic implementation. + || platformArch platform == ArchWasm32 + -- WASM doesn't support native FMA instructions (at the time of writing). + -> const False + + -- FNMSub and FNMAdd have different semantics on PowerPC, + -- so we avoid using them. + | ppc + -> \ case { FMAdd -> True; FMSub -> True; _ -> False } + + | otherwise + -> const True + , stgToCmmAllowIntMul2Instr = (ncg && x86ish) || llvm -- SIMD flags , stgToCmmVecInstrsErr = vec_err diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs index 7694975e80..84113df8eb 100644 --- a/compiler/GHC/Driver/Pipeline/Execute.hs +++ b/compiler/GHC/Driver/Pipeline/Execute.hs @@ -1028,6 +1028,7 @@ llvmOptions llvm_config dflags = ++ ["+avx512cd"| isAvx512cdEnabled dflags ] ++ ["+avx512er"| isAvx512erEnabled dflags ] ++ ["+avx512pf"| isAvx512pfEnabled dflags ] + ++ ["+fma" | isFmaEnabled dflags ] ++ ["+bmi" | isBmiEnabled dflags ] ++ ["+bmi2" | isBmi2Enabled dflags ] diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index 6a7ba74477..52361abb09 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -208,6 +208,7 @@ module GHC.Driver.Session ( isAvx512erEnabled, isAvx512fEnabled, isAvx512pfEnabled, + isFmaEnabled, -- * Linker/compiler information LinkerInfo(..), @@ -718,6 +719,7 @@ data DynFlags = DynFlags { avx512er :: Bool, -- Enable AVX-512 Exponential and Reciprocal Instructions. avx512f :: Bool, -- Enable AVX-512 instructions. avx512pf :: Bool, -- Enable AVX-512 PreFetch Instructions. + fma :: Bool, -- ^ Enable FMA instructions. -- | Run-time linker information (what options we need, etc.) rtldInfo :: IORef (Maybe LinkerInfo), @@ -1303,6 +1305,7 @@ defaultDynFlags mySettings = avx512er = False, avx512f = False, avx512pf = False, + fma = False, rtldInfo = panic "defaultDynFlags: no rtldInfo", rtccInfo = panic "defaultDynFlags: no rtccInfo", rtasmInfo = panic "defaultDynFlags: no rtasmInfo", @@ -2730,6 +2733,7 @@ dynamic_flags_deps = [ , make_ord_flag defGhcFlag "mavx512f" (noArg (\d -> d { avx512f = True })) , make_ord_flag defGhcFlag "mavx512pf" (noArg (\d -> d { avx512pf = True })) + , make_ord_flag defGhcFlag "mfma" (noArg (\d -> d { fma = True })) ------ Plugin flags ------------------------------------------------ , make_ord_flag defGhcFlag "fplugin-opt" (hasArg addPluginModuleNameOption) @@ -5008,7 +5012,7 @@ setUnsafeGlobalDynFlags dflags = do -- ----------------------------------------------------------------------------- --- SSE and AVX +-- SSE, AVX, FMA isSse4_2Enabled :: DynFlags -> Bool isSse4_2Enabled dflags = sseVersion dflags >= Just SSE42 @@ -5031,6 +5035,9 @@ isAvx512fEnabled dflags = avx512f dflags isAvx512pfEnabled :: DynFlags -> Bool isAvx512pfEnabled dflags = avx512pf dflags +isFmaEnabled :: DynFlags -> Bool +isFmaEnabled dflags = fma dflags + -- ----------------------------------------------------------------------------- -- BMI2 @@ -5046,6 +5053,8 @@ isBmi2Enabled dflags = case platformArch (targetPlatform dflags) of ArchX86 -> bmiVersion dflags >= Just BMI2 _ -> False +-- ----------------------------------------------------------------------------- + -- | Indicate if cost-centre profiling is enabled sccProfilingEnabled :: DynFlags -> Bool sccProfilingEnabled dflags = profileIsProfiling (targetProfile dflags) |