Treat some standard data cons specially during vectorisation
[ghc-hetmet.git] / compiler / vectorise / Vectorise.hs
index 63575b9..80c896c 100644 (file)
@@ -216,6 +216,8 @@ vectLiteral lit
       return (Lit lit, lexpr)
 
 vectPolyExpr :: CoreExprWithFVs -> VM VExpr
+vectPolyExpr (_, AnnNote note expr)
+  = liftM (vNote note) $ vectPolyExpr expr
 vectPolyExpr expr
   = polyAbstract tvs $ \abstract ->
     do
@@ -241,6 +243,17 @@ vectExpr e@(_, AnnApp _ arg)
   where
     (fn, tys) = collectAnnTypeArgs e
 
+vectExpr (_, AnnApp (_, AnnVar v) (_, AnnLit lit))
+  | Just con <- isDataConId_maybe v
+  , is_special_con con
+  = do
+      let vexpr = App (Var v) (Lit lit)
+      lexpr <- liftPA vexpr
+      return (vexpr, lexpr)
+  where
+    is_special_con con = con `elem` [intDataCon, floatDataCon, doubleDataCon]
+                
+
 vectExpr (_, AnnApp fn arg)
   = do
       arg_ty' <- vectType arg_ty
@@ -335,6 +348,14 @@ vectAlgCase tycon ty_args scrut bndr ty [(DEFAULT, [], body)]
       (vbndr, vbody) <- vectBndrIn bndr (vectExpr body)
       return $ vCaseDEFAULT vscrut vbndr vty lty vbody
 
+vectAlgCase tycon ty_args scrut bndr ty [(DataAlt dc, [], body)]
+  = do
+      vscrut <- vectExpr scrut
+      vty    <- vectType ty
+      lty    <- mkPArrayType vty
+      (vbndr, vbody) <- vectBndrIn bndr (vectExpr body)
+      return $ vCaseDEFAULT vscrut vbndr vty lty vbody
+
 vectAlgCase tycon ty_args scrut bndr ty [(DataAlt dc, bndrs, body)]
   = do
       vect_tc <- maybeV (lookupTyCon tycon)
@@ -446,6 +467,7 @@ packLiftingContext len shape tag fvs res_ty p
                 $ varSetElems fvs
           (vexpr, lexpr) <- p
           return (vexpr, Let (NonRec sel_var sel_expr)
+                         . mkLets (concat bnds)
                          $ Case len lc_var res_ty [(DEFAULT, [], lexpr)])
 
 packFreeVar :: CoreExpr -> CoreExpr -> Var -> VM [CoreBind]