From 8d5e92db87d0afaa3c45bb62bdde0745ffb60e34 Mon Sep 17 00:00:00 2001 From: Roman Leshchinskiy Date: Thu, 26 Jul 2007 05:21:08 +0000 Subject: [PATCH] Fix generation of lengthPA --- compiler/vectorise/VectMonad.hs | 5 ++++- compiler/vectorise/VectType.hs | 15 +++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/compiler/vectorise/VectMonad.hs b/compiler/vectorise/VectMonad.hs index 944f8c8..0329af8 100644 --- a/compiler/vectorise/VectMonad.hs +++ b/compiler/vectorise/VectMonad.hs @@ -3,7 +3,7 @@ module VectMonad ( VM, noV, tryV, maybeV, orElseV, fixV, localV, closedV, initV, - cloneName, newExportedVar, newLocalVar, newTyVar, + cloneName, newExportedVar, newLocalVar, newDummyVar, newTyVar, Builtins(..), paDictTyCon, paDictDataCon, builtin, @@ -297,6 +297,9 @@ newLocalVar fs ty u <- liftDs newUnique return $ mkSysLocal fs u ty +newDummyVar :: Type -> VM Var +newDummyVar = newLocalVar FSLIT("ds") + newTyVar :: FastString -> Kind -> VM Var newTyVar fs k = do diff --git a/compiler/vectorise/VectType.hs b/compiler/vectorise/VectType.hs index d3a1ee2..aed3e2a 100644 --- a/compiler/vectorise/VectType.hs +++ b/compiler/vectorise/VectType.hs @@ -315,20 +315,23 @@ paMethods = [(FSLIT("lengthPA"), buildLengthPA), (FSLIT("replicatePA"), buildReplicatePA)] buildLengthPA :: TyCon -> TyCon -> VM CoreExpr -buildLengthPA _ arr_tc +buildLengthPA vect_tc arr_tc = do - arg <- newLocalVar FSLIT("xs") arg_ty + parr_ty <- mkPArrayType (mkTyConApp vect_tc arg_tys) + arg <- newLocalVar FSLIT("xs") parr_ty + let scrut = unwrapFamInstScrut arr_tc arg_tys (Var arg) + scrut_ty = exprType scrut shape <- newLocalVar FSLIT("sel") shape_ty body <- lengthPA (Var shape) + wilds <- mapM newDummyVar repr_tys return . Lam arg - $ Case (Var arg) (mkWildId arg_ty) intPrimTy - [(DataAlt repr_dc, shape : map mkWildId repr_tys, body)] + $ Case scrut (mkWildId scrut_ty) intPrimTy + [(DataAlt repr_dc, shape : wilds, body)] where - arg_ty = mkTyConApp arr_tc . mkTyVarTys $ tyConTyVars arr_tc + arg_tys = mkTyVarTys $ tyConTyVars arr_tc [repr_dc] = tyConDataCons arr_tc shape_ty : repr_tys = dataConRepArgTys repr_dc - -- data T = C0 t1 ... tm -- ... -- Ck u1 ... un -- 1.7.10.4