• Sylvain Henry's avatar
    Scrutinee Constant Folding · d3b546b1
    Sylvain Henry authored
    This patch introduces new rules to perform constant folding through
    case-expressions.
    
    E.g.,
    ```
    case t -# 10# of _ {  ===> case t of _ {
             5#      -> e1              15#     -> e1
             8#      -> e2              18#     -> e2
             DEFAULT -> e               DEFAULT -> e
    ```
    
    The initial motivation is that it allows "Merge Nested Cases"
    optimization to kick in and to further simplify the code
    (see Trac #12877).
    
    Currently we recognize the following operations for Word# and Int#: Add,
    Sub, Xor, Not and Negate (for Int# only).
    
    Test Plan: validate
    
    Reviewers: simonpj, austin, bgamari
    
    Reviewed By: simonpj, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2762
    
    GHC Trac Issues: #12877
    d3b546b1
DynFlags.hs 215 KB