mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 13:23:47 +00:00
Estimated hours taken: 4 compiler/frameopt: Bug fix: make sure that the transformation that keeps stack frames put the instruction that restores succip before a livevals/goto pair. It used to put it in between the livevals and the goto, which violates an invariant that value numbering depends on. compiler/vn_table: Allow the two operands of an operator to be the same. compiler/vn_util: Add simplification rules for dealing with boolean and and or, and rules exploiting the identities of several operators. tests/hard_coded/float_map: A test case for the fix to builtin_float_compare recently checked in by Fergus. tests/hard_coded/Mmake: Enable the new test case. tests/valid/livevals_seq: A new test case for the fix to frameopt. tests/valid/double_vn: A new test case for the fix to vn_table. tests/valid/Mmake: Enable the new test cases.
43 lines
1.2 KiB
Mathematica
43 lines
1.2 KiB
Mathematica
% This is a regression test. The compiler used to abort in this code
|
|
% when both frame optimization and value numbering were turned on but
|
|
% full jump optimization wasn't.
|
|
%
|
|
% The reason was that frameopt, in keeping the stack frame of det_insert_fcl,
|
|
% would generate the instruction sequence "livevals, assign to succip, goto",
|
|
% which violated an invariant expected by value numbering, namely that
|
|
% the livevals giving info about the variables live at a goto must
|
|
% immediately precede the goto. (Fulljump fixes the problem by eliminating
|
|
% the goto.)
|
|
|
|
:- module livevals_seq.
|
|
:- interface.
|
|
:- import_module list, tree234.
|
|
|
|
:- type map(K,V) == tree234(K,V).
|
|
|
|
:- pred det_insert_fcl(map(K,V), list(K),
|
|
list(V), map(K,V)).
|
|
:- mode det_insert_fcl(in, in, in, out) is det.
|
|
|
|
:- implementation.
|
|
:- import_module require.
|
|
|
|
det_insert_fcl(Map0, Ks, Vs, Map) :-
|
|
(
|
|
Ks = [Key | Keys], Vs = [Value | Values]
|
|
->
|
|
det_insert(Map0, Key, Value, Map1),
|
|
det_insert_fcl(Map1, Keys, Values, Map)
|
|
;
|
|
Ks = [], Vs = []
|
|
->
|
|
Map = Map0
|
|
;
|
|
error("lists do not correspond")
|
|
).
|
|
|
|
:- pred det_insert(map(K,V), K, V, map(K,V)).
|
|
:- mode det_insert(in, in, in, out) is det.
|
|
|
|
:- external(det_insert/4).
|