Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : simd
http://hackage.haskell.org/trac/ghc/changeset/45b74dc463055a0249981d96f8feda1b1c5eba85 >--------------------------------------------------------------- commit 45b74dc463055a0249981d96f8feda1b1c5eba85 Author: Geoffrey Mainland <[email protected]> Date: Wed Nov 2 12:02:39 2011 +0000 Tell LLVM that all vector stores and loads are potentially unaligned. >--------------------------------------------------------------- compiler/llvmGen/Llvm/PpLlvm.hs | 26 ++++++++++++++++++++++---- compiler/llvmGen/Llvm/Types.hs | 5 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/compiler/llvmGen/Llvm/PpLlvm.hs b/compiler/llvmGen/Llvm/PpLlvm.hs index 217d02d..f62d7bd 100644 --- a/compiler/llvmGen/Llvm/PpLlvm.hs +++ b/compiler/llvmGen/Llvm/PpLlvm.hs @@ -255,13 +255,31 @@ ppAssignment :: LlvmVar -> Doc -> Doc ppAssignment var expr = (text $ getName var) <+> equals <+> expr -ppLoad :: LlvmVar -> Doc -ppLoad var = text "load" <+> texts var +-- XXX: On x86, vector types need to be 16-byte aligned for aligned access, but +-- we have no way of guaranteeing that this is true with GHC (we would need to +-- modify the layout of the stack and closures, change the storage manager, +-- etc.). So, we blindly tell LLVM that *any* vector store or load could be +-- unaligned. In the future we may be able to guarantee that certain vector +-- access patterns are aligned, in which case we will need a more granular way +-- of specifying alignment. +ppLoad :: LlvmVar -> Doc +ppLoad var + | isVecPtrVar var = text "load" <+> texts var <> + comma <+> text "align 1" + | otherwise = text "load" <+> texts var + where + isVecPtrVar :: LlvmVar -> Bool + isVecPtrVar = isVec . pLower . getVarType ppStore :: LlvmVar -> LlvmVar -> Doc -ppStore val dst = text "store" <+> texts val <> comma <+> texts dst - +ppStore val dst + | isVecPtrVar dst = text "store" <+> texts val <> comma <+> texts dst <> + comma <+> text "align 1" + | otherwise = text "store" <+> texts val <> comma <+> texts dst + where + isVecPtrVar :: LlvmVar -> Bool + isVecPtrVar = isVec . pLower . getVarType ppCast :: LlvmCastOp -> LlvmVar -> LlvmType -> Doc ppCast op from to = texts op <+> texts from <+> text "to" <+> texts to diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs index c41c268..2e73351 100644 --- a/compiler/llvmGen/Llvm/Types.hs +++ b/compiler/llvmGen/Llvm/Types.hs @@ -281,6 +281,11 @@ isPointer :: LlvmType -> Bool isPointer (LMPointer _) = True isPointer _ = False +-- | Test if the given 'LlvmType' is an 'LMVector' construct +isVec :: LlvmType -> Bool +isVec (LMVector {}) = True +isVec _ = False + -- | Test if a 'LlvmVar' is global. isGlobal :: LlvmVar -> Bool isGlobal (LMGlobalVar _ _ _ _ _ _) = True _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
