[commit: ghc] master: Vectoriser: binders of encapsulated lambdas need to be scalar (7cfed20)

Manuel Chakravarty chak at cse.unsw.edu.au
Wed Feb 6 04:17:22 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/7cfed20d66512291697b9971fc1351c7e82f241c

>---------------------------------------------------------------

commit 7cfed20d66512291697b9971fc1351c7e82f241c
Author: Manuel M T Chakravarty <chak at cse.unsw.edu.au>
Date:   Mon Feb 4 14:28:50 2013 +1100

    Vectoriser: binders of encapsulated lambdas need to be scalar

>---------------------------------------------------------------

 compiler/vectorise/Vectorise/Exp.hs |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/compiler/vectorise/Vectorise/Exp.hs b/compiler/vectorise/Vectorise/Exp.hs
index dd81e32..adc5e96 100644
--- a/compiler/vectorise/Vectorise/Exp.hs
+++ b/compiler/vectorise/Vectorise/Exp.hs
@@ -161,7 +161,7 @@ vectAnnPolyExpr loop_breaker expr
 encapsulateScalars :: CoreExprWithVectInfo -> VM CoreExprWithVectInfo
 encapsulateScalars ce@(_, AnnType _ty)
   = return ce
-encapsulateScalars ce@((_, VISimple), AnnVar v)
+encapsulateScalars ce@((_, VISimple), AnnVar _v)
       -- NB: diverts from the paper: encapsulate variables with scalar type (includes functions)
   = liftSimpleAndCase ce
 encapsulateScalars ce@(_, AnnVar _v)
@@ -175,14 +175,20 @@ encapsulateScalars ((fvs, vi), AnnTick tck expr)
     }
 encapsulateScalars ce@((fvs, vi), AnnLam bndr expr) 
   = do 
-    { varsS <- allScalarVarTypeSet fvs 
-    ; case (vi, varsS) of
+    { varsS  <- allScalarVarTypeSet fvs 
+        -- NB: diverts from the paper: we need to check the scalarness of bound variables as well,
+        --     as 'vectScalarFun' will handle them just the same as those introduced for the 'fvs'
+        --     by encapsulation.
+    ; bndrsS <- allScalarVarType bndrs
+    ; case (vi, varsS && bndrsS) of
         (VISimple, True) -> liftSimpleAndCase ce
         _                -> do 
                             { encExpr <- encapsulateScalars expr
                             ; return ((fvs, vi), AnnLam bndr encExpr)
                             }
     }
+  where
+    (bndrs, _) = collectAnnBndrs ce
 encapsulateScalars ce@((fvs, vi), AnnApp ce1 ce2)
   = do
     { varsS <- allScalarVarTypeSet fvs





More information about the ghc-commits mailing list