Algebraically simplify add/sub with carry/overflow
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 counterparts. 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
Showing
- compiler/basicTypes/Literal.hs 36 additions, 12 deletionscompiler/basicTypes/Literal.hs
- compiler/prelude/PrelRules.hs 78 additions, 1 deletioncompiler/prelude/PrelRules.hs
- testsuite/tests/numeric/should_run/T10962.hs 21 additions, 5 deletionstestsuite/tests/numeric/should_run/T10962.hs
- testsuite/tests/numeric/should_run/T10962.stdout-ws-32 7 additions, 1 deletiontestsuite/tests/numeric/should_run/T10962.stdout-ws-32
- testsuite/tests/numeric/should_run/T10962.stdout-ws-64 7 additions, 1 deletiontestsuite/tests/numeric/should_run/T10962.stdout-ws-64
- testsuite/tests/numeric/should_run/all.T 1 addition, 1 deletiontestsuite/tests/numeric/should_run/all.T
Loading
Please register or sign in to comment