Skip to content
  • Joachim Breitner's avatar
    dcf30da8
    Drop the app invariant · dcf30da8
    Joachim Breitner authored and Marge Bot's avatar Marge Bot committed
    
    
    previously, GHC had the "let/app-invariant" which said that the RHS of a
    let or the argument of an application must be of lifted type or ok for
    speculation. We want this on let to freely float them around, and we
    wanted that on app to freely convert between the two (e.g. in
    beta-reduction or inlining).
    
    However, the app invariant meant that simple code didn't stay simple and
    this got in the way of rules matching. By removing the app invariant,
    this thus fixes #20554.
    
    The new invariant is now called "let-can-float invariant", which is
    hopefully easier to guess its meaning correctly.
    
    Dropping the app invariant means that everywhere where we effectively do
    beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe`
    and other innocent looking places) we now have to check if the argument
    must be evaluated (unlifted and side-effecting), and analyses have to be
    adjusted to the new semantics of `App`.
    
    Also, `LetFloats` in the simplifier can now also carry such non-floating
    bindings.
    
    The fix for DmdAnal, refine by Sebastian, makes functions with unlifted
    arguments strict in these arguments, which changes some signatures.
    
    This causes some extra calls to `exprType` and `exprOkForSpeculation`,
    so some perf benchmarks regress a bit (while others improve).
    
    Metric Decrease:
        T9020
    Metric Increase:
        LargeRecord
        T12545
        T15164
        T16577
        T18223
        T5642
        T9961
    
    Co-authored-by: default avatarSebastian Graf <sebastian.graf@kit.edu>
    dcf30da8
    Drop the app invariant
    Joachim Breitner authored and Marge Bot's avatar Marge Bot committed
    
    
    previously, GHC had the "let/app-invariant" which said that the RHS of a
    let or the argument of an application must be of lifted type or ok for
    speculation. We want this on let to freely float them around, and we
    wanted that on app to freely convert between the two (e.g. in
    beta-reduction or inlining).
    
    However, the app invariant meant that simple code didn't stay simple and
    this got in the way of rules matching. By removing the app invariant,
    this thus fixes #20554.
    
    The new invariant is now called "let-can-float invariant", which is
    hopefully easier to guess its meaning correctly.
    
    Dropping the app invariant means that everywhere where we effectively do
    beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe`
    and other innocent looking places) we now have to check if the argument
    must be evaluated (unlifted and side-effecting), and analyses have to be
    adjusted to the new semantics of `App`.
    
    Also, `LetFloats` in the simplifier can now also carry such non-floating
    bindings.
    
    The fix for DmdAnal, refine by Sebastian, makes functions with unlifted
    arguments strict in these arguments, which changes some signatures.
    
    This causes some extra calls to `exprType` and `exprOkForSpeculation`,
    so some perf benchmarks regress a bit (while others improve).
    
    Metric Decrease:
        T9020
    Metric Increase:
        LargeRecord
        T12545
        T15164
        T16577
        T18223
        T5642
        T9961
    
    Co-authored-by: default avatarSebastian Graf <sebastian.graf@kit.edu>
Loading