From 17229f40149d4ff892930f76d1caaff6d3d4a189 Mon Sep 17 00:00:00 2001 From: Hans Svensson Date: Wed, 23 Aug 2023 13:16:57 +0200 Subject: [PATCH] Improve independence analysis --- src/aeso_fcode_to_fate.erl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/aeso_fcode_to_fate.erl b/src/aeso_fcode_to_fate.erl index 5c99d70..96ffe69 100644 --- a/src/aeso_fcode_to_fate.erl +++ b/src/aeso_fcode_to_fate.erl @@ -1141,11 +1141,16 @@ independent({i, _, I}, {i, _, J}) -> StackI = lists:member(?a, [WI | RI]), StackJ = lists:member(?a, [WJ | RJ]), - if WI == pc; WJ == pc -> false; %% no jumps - not (PureI or PureJ) -> false; %% at least one is pure - StackI and StackJ -> false; %% cannot both use the stack - WI == WJ -> false; %% cannot write to the same register - true -> + ReadStoreI = [] /= [ x || {store, _} <- RI ], + ReadStoreJ = [] /= [ x || {store, _} <- RJ ], + + if WI == pc; WJ == pc -> false; %% no jumps + not (PureI or PureJ) -> false; %% at least one is pure + StackI and StackJ -> false; %% cannot both use the stack + WI == WJ -> false; %% cannot write to the same register + ReadStoreI and not PureJ -> false; %% can't read store/state if other is impure + ReadStoreJ and not PureI -> false; %% can't read store/state if other is impure + true -> %% and cannot write to each other's inputs not lists:member(WI, RJ) andalso not lists:member(WJ, RI)