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

On branch  : simd

http://hackage.haskell.org/trac/ghc/changeset/a72a946c2ef0f15b89dda0164f36ee89179cee52

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

commit a72a946c2ef0f15b89dda0164f36ee89179cee52
Author: Geoffrey Mainland <[email protected]>
Date:   Tue Nov 15 12:10:14 2011 +0000

    Fix vector element insertion and deletion.
    
    Vector indices must always be 32-bit integers, even on 64-bit machines. We 
were
    using the native word size before.

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

 compiler/codeGen/CgPrimOp.hs |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/compiler/codeGen/CgPrimOp.hs b/compiler/codeGen/CgPrimOp.hs
index d6cb9f2..5f4d638 100644
--- a/compiler/codeGen/CgPrimOp.hs
+++ b/compiler/codeGen/CgPrimOp.hs
@@ -772,13 +772,17 @@ doVecInsert :: Maybe MachOp  -- Cast from element to 
vector component
             -> Code
 doVecInsert maybe_pre_write_cast ty src e idx res =
     stmtC $ CmmAssign (CmmLocal res)
-                      (CmmMachOp (MO_V_Insert len wid) [src, cast e, idx])
+                      (CmmMachOp (MO_V_Insert len wid) [src, cast e, idx'])
   where
     cast :: CmmExpr -> CmmExpr
     cast val = case maybe_pre_write_cast of
                  Nothing   -> val
                  Just cast -> CmmMachOp cast [val]
 
+    -- vector indices are always 32-bits
+    idx' :: CmmExpr
+    idx' = CmmMachOp (MO_SS_Conv wordWidth W32) [idx]
+
     len :: Length
     len = vecLength ty 
 
@@ -805,7 +809,8 @@ doVecPack maybe_pre_write_cast ty es res = do
                                      [CmmReg (CmmLocal src), cast e, iLit])
         vecPack dst es (i + 1)
       where
-        iLit = CmmLit (mkIntCLit i)
+        -- vector indices are always 32-bits
+        iLit = CmmLit (CmmInt (toInteger i) W32)
 
     cast :: CmmExpr -> CmmExpr
     cast val = case maybe_pre_write_cast of
@@ -836,7 +841,8 @@ doVecUnpack maybe_post_read_cast ty e res =
                                            [e, iLit]))
         vecUnpack rs (i + 1)
       where
-        iLit = CmmLit (mkIntCLit i)
+        -- vector indices are always 32-bits
+        iLit = CmmLit (CmmInt (toInteger i) W32)
 
     cast :: CmmExpr -> CmmExpr
     cast val = case maybe_post_read_cast of



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to