Skip to content

Only use active rules when simplifying rule RHSs

sheaf requested to merge sheaf/ghc:T26323 into master

Ticket: #26323 (closed)

When we are simplifying the RHS of a rule, we make sure to only apply rewrites from rules that are active throughout the original rule's range of active phases.

For example, if a rule is always active, we only fire rules that are themselves always active when simplifying the RHS. Ditto for inline activations.

This is achieved by setting the simplifier phase to a range of phases, using the new SimplPhaseRange constructor. Then:

  1. When simplifying the RHS of a rule, or of a stable unfolding, we set the simplifier phase to a range of phases, computed from the current simplifier phase and the RULE/unfolding activation, using the new function phaseRangeFromActivation.

    The details are explained in Note [What is active in the RHS of a RULE?] in GHC.Core.Opt.Simplify.Utils.

  2. The activation check for other rules and inlinings is then: does the activation of the other rule/inlining cover the whole phase range set in sm_phase? This continues to use the isActive function, which now accounts for phase ranges.

On the way, this MR also moves the exact-print SourceText annotation from the Activation datatype to the ActivationAnn type. This keeps the main Activation datatype free of any extra cruft.

Edited by sheaf

Merge request reports

Loading