Files
mercury/tests/hard_coded/constant_prop_loop_inv.exp
Zoltan Somogyi 48e714d43f Make constant prop work with loop invariant opt.
compiler/common.m:
    The code that tries to optimize X = f(...) into X = Y if Y already
    contains f(...) used to insist on the X = f(...) construction unification
    being marked as a dynamic unification, i.e. one that constructs a term
    on the heap on each invocation. This was part of the fix of Mantis bug
    #493, which affected only the MLDS code generator, but for LLDS backend,
    in the presence of --loop-invariants, it prevented a constant propagation
    optimization that we had a test for (tests/hard_coded/constant_prop_2).
    So make both backends happy by insisting on construct_dynamically
    only for the MLDS backend.

compiler/simplify_info.m:
    Record for common.m whether the backend we are targeting pays
    any attention to whether a cell is construct_dynamically.

    Replace some bools with bespoke types, to eliminate the risk of confusion.

compiler/hlds_goal.m:
    For each construction unification marked construct_statically, record
    whether the term was "born static" by being created as a static term
    by a compiler pass, or whether it is a user-written unification that was
    "marked static" by mark_static_terms.m. Document the meaning of both.
    (I originally thought this distinction would be useful in the bug fix,
    but it turned out not to be.)

compiler/deep_profiling.m:
compiler/dep_par_conj.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/polymorphism.m:
compiler/polymorphism_type_info.m:
    Record compiler-generated static terms as born static.

compiler/mark_static_terms.m:
    Mark discovered-to-be-static terms as marked static.

compiler/hlds_out_goal.m:
compiler/interval.m:
compiler/liveness.m:
compiler/loop_inv.m:
compiler/ml_unify_gen_construct.m:
compiler/quantification.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/simplify_goal.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_scope.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.versions.m:
compiler/unify_gen_construct.m:
compiler/var_locn.m:
    Conform to the changes above.

tests/hard_coded/constant_prop_loop_inv.{m,exp}:
    A new test case. It contains the part of the constant_prop_2 test case
    that used to fail in LLDS grades with --loop-invariants.

tests/hard_coded/Mercury.options:
    Specify --loop-invariants for the new test case, even if it is not
    specified for constant_prop_2.

tests/hard_coded/Mmakefile:
    Enable the new test case.

tests/hard_coded/constant_prop_2.m:
    Fix programming style.
2021-05-13 13:34:07 +10:00

2 lines
4 B
Plaintext