diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-03-27 10:35:59 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-03-27 10:35:59 +0100 |
commit | a994883ef5b08c16e6331f5f4dbde6a650856bc1 (patch) | |
tree | 5b1abe40642b7b92e60e9dddddec0a9a7bdb8d4c /src/Compile.hs | |
parent | 022cc042d95c1a9cad12b62da9e994de28ab4bc5 (diff) |
Compile: Decrement accumval only when added, not moved
Diffstat (limited to 'src/Compile.hs')
-rw-r--r-- | src/Compile.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Compile.hs b/src/Compile.hs index c134824..4e60ace 100644 --- a/src/Compile.hs +++ b/src/Compile.hs @@ -1020,13 +1020,15 @@ compile' env = \case shsizename <- genName' "acshsz" ivar <- genName' "i" ((), stmts1) <- scope $ add t1 (d++".j.buf->xs["++ivar++"]") (s++".j.buf->xs["++ivar++"]") + ((), stmtsDecr) <- scope $ incrementVarAlways "accumarr" Decrement (STArr n (CHAD.d2 t1)) (s++".j") emit $ SIf (CEBinop (CELit (s++".tag")) "==" (CELit "1")) (pure (SIf (CEBinop (CELit (d++".tag")) "==" (CELit "0")) (pure (SAsg d (CELit s))) (pure (SVarDecl True (repSTy tIx) shsizename (compileArrShapeSize n (s++".j"))) -- TODO: emit check here for the source being either equal in shape to the destination <> pure (SLoop (repSTy tIx) ivar (CELit "0") (CELit shsizename) - stmts1)))) + stmts1) + <> stmtsDecr))) mempty add (STScal sty) d s = case sty of STI32 -> return () @@ -1039,8 +1041,6 @@ compile' env = \case emit $ SVerbatim $ "// compile EAccum start (" ++ show prj ++ ")" dest <- accumRef t prj (nameacc++".buf->ac") nameidx add (acPrjTy prj t) dest nameval - - incrementVarAlways "accumval" Decrement (typeOf eval) nameval emit $ SVerbatim $ "// compile EAccum end" return $ CEStruct (repSTy STNil) [] |