Files
mercury/tests/hard_coded/nondet_ctrl_vn.m
Zoltan Somogyi 559d1ea5ce Fix a bug in value numbering reported by Simon.
Estimated hours taken: 1

Fix a bug in value numbering reported by Simon.

compiler/vn_block.m:
	Restore a previously commented block of code, whose job is to force
	the flushing of any stack slot that holds the saved value of a nondet
	control register or stack slot. The rationale for this code used
	to be the handling of cuts in nondet code; now it is the handling
	of hijackings.

tests/hard_coded.{m,exp}:
	A cut-down and inlined version of Simon's test case, which fails
	without the change to vn_block and succeeds with it.

tests/hard_coded/Mmakefile:
	Enable the new test case, and require that it be compiled with
	value numbering.
1998-08-26 07:52:01 +00:00

42 lines
752 B
Mathematica

% This is a regression test. The 1998 August 24 version of the compiler
% generated incorrect code for this module, the bug being that the value
% numbering pass did not properly flush stack slots that hold the old values
% of hijacked nondet control slots.
%
% This is a cut-down version of cut_test.m
:- module nondet_ctrl_vn.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module int.
main -->
( { middle(100) } ->
io__write_string("test succeeded: BUG.\n")
;
io__write_string("test failed: OK.\n")
).
:- pragma no_inline(middle/1).
:- pred middle(int::in) is semidet.
middle(A0) :-
(
A is A0 + 10
;
A is A0 + 20
),
A > 200,
(
B is A
;
B is A * 2
).