Calling a function which takes SIMD vectors causes a segfault
The following program which uses SIMD vectors reliably segfaults. (Currently the only backend that supports SIMD is the LLVM backend, but it segfaults with the native backend I am adding to GHC as well.)
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Main where
import GHC.Exts
main :: IO ()
main =
case foo ( \ x y -> plusDoubleX2# x y ) of
v -> case unpackDoubleX2# v of
(# d1, d2 #) ->
print [ D# d1, D# d2 ]
{-# NOINLINE foo #-}
foo :: ( DoubleX2# -> DoubleX2# -> DoubleX2# ) -> DoubleX2#
foo f =
case packDoubleX2# (# 10.01##, 20.02## #) of
!x -> f x x
To reproduce, compile this file and run it. For instance, with the LLVM backend, ghc Main.hs -fllvm
. This will segfault somewhere inside stg_ap_v16_fast
.
Looking at the assembly, the code before the jump to stg_ap_v16_fast
seem correct to me, so I currently suspect that stg_ap_v16_fast
is at fault (I may be wrong).
Edited by sheaf