on master help sign in
javascript: fix elimination of conditions #1192
a68c5faraichoo
src/IRTS/CodegenJavaScript.hs+21−8
@@ -1424,17 +1424,30 @@ elimConds js =
1424 isCond :: JS -> Bool
1424 isCond :: JS -> Bool
1425 isCond (JSAlloc
1425 isCond (JSAlloc
1426 fun (Just (JSFunction args (JSCond
1426 fun (Just (JSFunction args (JSCond
1427− [ (JSBinOp "==" (JSNum (JSInt tag)) _, JSReturn (JSIdent _))
1427+ [ (JSBinOp "==" (JSNum (JSInt tag)) (JSProj (JSIdent _) "tag"), JSReturn t)
1428− , (JSNoop, JSReturn (JSIdent _))
1428+ , (JSNoop, JSReturn f)
1429− ]))
1429+ ])))
1430+ )
1431+ | isJSConstant t && isJSConstant f =
1432+ True
1433+
1434+ | JSIdent _ <- t
1435+ , JSIdent _ <- f =
1430− )) = True
1436+ True
1431
1437
1432 isCond (JSAlloc
1438 isCond (JSAlloc
1433 fun (Just (JSFunction args (JSCond
1439 fun (Just (JSFunction args (JSCond
1434− [ (JSBinOp "==" _ (JSNum (JSInt tag)), JSReturn (JSIdent _))
1440+ [ (JSBinOp "==" (JSIdent _) c, JSReturn t)
1435− , (JSNoop, JSReturn (JSIdent _))
1441+ , (JSNoop, JSReturn f)
1436− ]))
1442+ ])))
1443+ )
1444+ | isJSConstant t && isJSConstant f && isJSConstant c =
1445+ True
1446+
1447+ | JSIdent _ <- t
1448+ , JSIdent _ <- f
1449+ , isJSConstant c =
1437− )) = True
1450+ True
1438
1451
1439 isCond _ = False
1452 isCond _ = False
1440
1453