Estimated hours taken: 20
det_analysis:
Make sure we don't change the goal being analyzed except possibly
for the introduction of `some's (which should not hurt anything).
Make sure we don't print any error messages except in the final
iteration, when all the inputs to the inference are stable.
If the --debug-detism options is set, print messages about the
progress of inference and checking.
Also moved some code around.
det_report:
Distinguish the handling of warning messages and error messages.
simplify:
Use the new ability of det_report to separate warnings and errors.
passes_aux:
Add a new generic pass form, for use by simplify.
option:
Add --debug-detism (as above), --aditi, which at the moment
only enables the disjunctive normal form transformation, and
--inlining/--no-inlining, which set the other three flags
involved in inlining depending on whether you want standard
inlining or none at all.
Follow_code used to be set twice and follow_vars not at all;
I fixed this.
Reenabled optimize_higher_order at -O3.
Moved value numbering to -O4 and pred_value_number to -O5.
This makes it easier to separate value numbering from the
other optimizations (which are likely to be more effective).
Divided options_help into sections to avoid excessive
compilation times.
store_alloc:
Base the store map on the follow_vars info attached to the
branched structure which I added recently, and not on the
follow_vars map being passed around, since it will be more accurate.
hlds_out:
Print information about follow_vars and store_maps when -D is given.
follow_code:
Undo an old hack that change to follow_vars has made counterproductive.
middle_rec:
Fix a bug uncovered by the change to follow_code. When looking for a
register to hold the counter, it is not enough to avoid picking a
register that appears in the recursive case; we must also avoid
registers that occur only in the base case.
livemap:
Mentioning the code address succip now causes the succip to be
considered live. This may or may not fix the bug with pred_value_number
miscompiling unused_args.m; the other changes have caused the input
to value numbering to change, and they no longer trigger the problem.
(Will try to test this later.)
mercury_compile:
Try to make sure that we print statistics only after passes that
were actually executed. Also, reduce the number of lookups of the
verbose option. Move some predicates so that the order of their
appearance matches the current order of invocation.
vn_table:
Loosen a sanity check to let xnuc2 pass through it.
code_exprn, switch_detection:
Minor changes.
Estimated hours taken: 6
compiler/{code_gen.pp,code_info.m,code_exprn.m}:
When generating semidet pragma c_codes, make sure to shuffle r1
out of the way in case its value is needed after the pragma.
Estimated hours taken: 2
Do some more work on improving floating-point performance:
emit boxed floating point constants as static ground terms.
options.m:
Add new option --unboxed-float.
exprn_aux.m
Add --unboxed-float to the `exprn_opts' that affect whether
or not things can be static constants. If --unboxed-float
is not set, and --static-ground-terms is, then consider
float_consts to be constant.
code_exprn.m, lookup_switch.m:
Trivial changes to handle new arity of exprn_opts type.
llds.m:
If --unboxed-float is not set, and --static-ground-terms is, then
output `static const Float mercury_float_const_...' declarations
for float_consts.
Estimated hours taken: 1
code_exprn:
Avoid creating unecessary shuffling operations. Specifically,
if a register (say r1) is live, and if you want to put a value
into it, we used to generate a sequence such as:
r2 = r1;
r1 = <some rval>;
Very often the original value of r1 is needed *only* in <some rval>.
We now generate this bad code as before, but then check whether
there are any live variables whose values *require* r2 (as opposed
to having one of their several copies accessible via r2). If not,
we remove the register copy.
Most of the work is done by the auxiliary predicates introduced
in the previous checkin.
This change reduces the size of the compiler by 65 Kb, almost 3%.
This is with standard optimization. Since this optimization removes
code that is also removed by value numbering, any gain in the
size of fully optimized code will be minimal.
Estimated hours taken: 4
code_exprn:
Made a start towards getting better code generated for nested creates
and towards getting rid of useless "shuffle lval" instructions.
Also, some minor cleanup.
exprn_aux:
Add some auxiliary predicates for the new code_exprn.
delay_info:
Remove a useless import of hlds, which is now empty.
Estimated hours taken: 1.5
code_exprn:
Distribute the initial comments among the declarations of the exported
predicates. This makes it much less likely that the declarations will
be modified without changes in the comments. Since this has happened
in the past, some predicates are now without comments.
Changed code_exprn__place_var to prefer to get even a constant term
from a location if it has been produced before, and factor out some
code that is shared between the handling of cached and evaled
expressions.
code_exprm, code_info:
Removed an unnecessary argument from code_exprn__get_varlocs.
dead_proc_elim:
Changed the predicate name prefix from dead__ to dead_proc_elim__
to conform to notes/CODING_STANDARDS.
handle_options:
Remove an inappropriate comment.
jumpopt:
Filter out redundant livevals whether --optimize-fulljumps is given
or not. (I thought they aren't created if the option isn't given,
but they are.)
options:
Change the meaning of -O from --c-optimize to --opt-level.
Disabled unused args until the bug is fixed.
Estimated hours taken: 2
code_exprn:
When we are processing the flushing of create expressions, make sure
the Lval we are creating into isn't a field reference. This avoids
deep field of field of field of ... nesting. It does introduce
references to high register numbers, but this is a lesser evil,
and Tom and I plan to fix this anyway.
arg_info, globals, options:
Change --args old to --args simple.
options:
Make some help messages more specific.
code_aux, code_exprn, code_info, det_report, make_hlds, mercury_to_goedel,
prog_io, typecheck:
Changes to accommodate the move from varset__lookup_name
to varset__search_name.
Estimated hours taken: 2
exprn_aux:
Both code_exprn and lookup_switch had code to check whether an
expression is constant or not. Some of the code is different
due to different handling of variables in rvals, but exprn_aux
now contains the common subset.
This common subset used to treat some address constants incorrectly,
simply by not considering them; they are now considered and treated
properly.
code_exprn, lookup_switch, exprn_aux:
Remove redundant option lookups in the process of checking for
constant expressions.
code_exprn:
Other minor cleanups, including removal of a block of code Tom
says was "deep magic" (but which turns out to be unnecessary).
code_info:
Removed some dead code.
options:
Added real support for --opt-level, in the form of a table of
default values of options for each optimization level between
0 and 5 (both inclusive). This needs a new form of documentation.
How do you do tables in texinfo?
Estimated hours taken: 6
mercury_to_mercury:
Wrap parentheses around pred insts, since they are needed.
value_number, vn_verify:
Value numbering now reapplies itself to both halves of a block if
it cannot optimize the block as a whole.
Split the verification code into its own module, and fix line lengths.
vn_order:
Fix the computation of the label at which blocks should be divided.
Fix line lengths.
vn_debug:
Add a message to support the new block dividing capability.
code_exprn:
Redirect option lookup operations from options to getopt.
passes_aux:
Prepare for some further changes.
prog_io:
Formatting changes.
Estimated hours taken: 1.5
Undo dylan's changes in the names of some library entities,
by applying the following sed script
s/term_atom/term__atom/g
s/term_string/term__string/g
s/term_integer/term__integer/g
s/term_float/term__float/g
s/term_context/term__context/g
s/term_functor/term__functor/g
s/term_variable/term__variable/g
s/_term__/_term_/g
s/std_util__bool_/bool__/g
to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).
I also moved `bool' to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)
compiler/*.m:
Apply sed script above;
where appropriate, add `bool' to the list of imported modules.
code_exprn.m:
Improve error message for one of the internal errors.
det_analysis.m:
Make sure we don't generated unnecessary nested `some' goals.
prog_io.m, inst_match.m, mode_util.m, mercury_to_mercury.m:
Add new insts `mostly_unique' and `mostly_clobbered', with
semantics similar to `unique' and `clobbered', except that
mostly-unique variables might be needed on backtracking.
unique_modes.m:
A good start on the code to check that `unique' modes
are not used for nondet live variables. Still incomplete,
but just about all the code is there except the code to
actually compute the set of nondet live variables as you
traverse the goal.
excess:
A new pass to remove unnecessary assignment unifications.
mercury_compile:
Call the new excess assignment module.
options:
Add a new option, excess_assign, to control the new optimization.
Add another, num-real-regs, to specify how many of r1, r2 etc are
actually real registers. The default is now set to 5 for kryten;
later it should be supplied by the mc script, with a value determined
at configuration time.
tag_switch:
Use num-real-regs to figure out whether it is likely to be worthwhile
to eliminate the common subexpression of taking the primary tag of
a variable. Also fix an old performance bug: the test for when a
jump table is worthwhile was reversed.
value_number, vn_block:
Do value numbering on extended basic blocks, not basic blocks.
vn_debug:
Modify an information message.
labelopt:
Clean up an export an internal predicate for value numbering. Replace
bintree_set with set.
middle_rec:
Prepare for the generalization of middle recursion optimization
to include predicates with an if-then-else structure.
cse_detection:
Fix a bug: when hoisting a common desconstruction X = f(Yi), create
new variables for the Yi. This avoids problems with any of the Yis
appearing in other branches of the code.
goal_util:
Add a new predicate for use by cse_detection.
common:
Fix a bug: recompute instmap deltas, since they may be affected by the
optimization of common structures.
code_info:
Make an error message more explicit.
det_analysis:
Restrict import list to the needed modules.
*.m:
Import assoc_list.
code_exprn.m, modes.m:
Fix singleton variable warnings by deleting useless code.
shapes.m, typecheck.m:
Fix singleton variable warnings by renaming variables so that they
start with an underscore.
make_hlds.m:
Pass the context down into transform_goal_2, unravel_unification,
insert_arg_unifications, and append_arg_unifications, so that
the goal_info_context in the newly built HLDS is never empty.
This is needed because the new warn_singletons uses the context,
so it has to be valid.
unify_proc.m:
Pass a term__context to unravel_unification (as required by
above change).
quantification.m:
Rearrange some comments that got shifted a dozen
lines from the code they referred to.
vn_util.m:
Fix omission in Zoltan's changes with `succip(FramePointer)'
which caused "Software Error: unexpected lval in vn_...".
modes.m:
Optimize away unifications with dead variables.
(The code generator already does that, but by
that time we have already allocated unnecessary
stack slots for them.)
code_exprn.m:
Avoid generating sequences such as `r2 = r3; r3 = r2;'
when a register already contains the correct value.
(This change was in fact at least as much Tom's work as mine.)
store_alloc.m:
For disjunctions, we only want to allocate registers
for the variables that are output by the disjunction.
The inputs should go in framevars, not in registers.
This avoids much of the register-shuffling
in the code generated for e.g. list__member(out, in).
(This change was in fact at least as much Tom's work as mine.)
frameopt:
Look inside blocks introduced by value numbering when looking
restorations of succip.
value_number, opt_util:
If we are using conservative garbage collection, disable value
numbering for blocks that allocate more than one cell on the heap.
This allows value numbering of most blocks to work in the absence
of -DALL_INTERIOR_POINTERS.
all other source files:
Clean up "blank" lines that nevertheless contain space or tab
characters.
code_exprn.m:
Double bug fix. Static ground terms were not being correctly
handled. Neither were partially instantiated terms. Both are
now handled correctly (famous last words, no doubt).
det_analysis.m:
I thought I'd committed this change at *least* once before
(though I havn;t checked the revision history). I fixed the
code generator bug that was causing a commented out section
to fail. So I've uncommented out that section.
code*.m & *gen.m:
Implement an improved method of handling negated contexts.
The new method avoids saving things onto the stack before
an if-then-else or negation if it can.
Also, fix the implementation of nondet if-then-else so that
it does the soft cut properly.
code_exprn.m:
Fix a bug that was causing the code generator to loose
track of how many references there are to a register.
The bug was what caused incorrect results for one of
Bart's programs.
compiler/*:
Add copyright messages.
Change all occurences of *.nl in comments to *.m.
compiler/mercury_compile.pp:
Change the output to the .dep files to use *.m rather than *.nl.
(NOTE: this means that `mmake' will not work any more if you
call your files *.nl!!!)
code_exprn.m
code_info.m:
Fix an overly conservative sanity check.
mercury_compile.pp
typecheck.m:
Fix type errors due to the changed implementation of map.
Possibly these bits of code should be removed or something
so that map is properly abstract.
exprn_aux.nl:
a new module for manipulating rvals and lvals.
code_exprn.nl:
the new bottom level of the new code generator. This replaces
a large chunk of code_info.
*code* & *gen*:
various small changes to use the new bottom level of the
code generator.