Improve independence analysis

This commit is contained in:
Hans Svensson 2023-08-23 13:16:57 +02:00
parent 3b0ca28c8e
commit 17229f4014

View File

@ -1141,11 +1141,16 @@ independent({i, _, I}, {i, _, J}) ->
StackI = lists:member(?a, [WI | RI]), StackI = lists:member(?a, [WI | RI]),
StackJ = lists:member(?a, [WJ | RJ]), StackJ = lists:member(?a, [WJ | RJ]),
if WI == pc; WJ == pc -> false; %% no jumps ReadStoreI = [] /= [ x || {store, _} <- RI ],
not (PureI or PureJ) -> false; %% at least one is pure ReadStoreJ = [] /= [ x || {store, _} <- RJ ],
StackI and StackJ -> false; %% cannot both use the stack
WI == WJ -> false; %% cannot write to the same register if WI == pc; WJ == pc -> false; %% no jumps
true -> 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 %% and cannot write to each other's inputs
not lists:member(WI, RJ) andalso not lists:member(WI, RJ) andalso
not lists:member(WJ, RI) not lists:member(WJ, RI)