• Sebastian Graf's avatar
    Algebraically simplify add/sub with carry/overflow · bb338f2e
    Sebastian Graf authored
    Previously, the `{add,sub}{Int,Word}C#` PrimOps weren't handled
    in PrelRules (constant folding and algebraic simplification) at all.
    This implements the necessary logic, so that using these primitives
    isn't too punishing compared to their well-optimised, overflow-unaware
    This is so that using these primitives in `enumFromThenTo @Int` can
    be optimized by constant folding, reducing closure sizes.
    Reviewers: bgamari, simonpj, hsyl20
    Reviewed By: bgamari, simonpj
    Subscribers: AndreasK, thomie, carter
    GHC Trac Issues: #8763
    Differential Revision: https://phabricator.haskell.org/D4605
PrelRules.hs 70.8 KB