• rwbarton's avatar
    When floating, don't box an expression that's okay for speculation (#13338) · d0508ef0
    rwbarton authored
    Commit 432f952e (Float unboxed expressions by boxing) lets the float-out pass
    turn, for example,
    
        ... (-# (remInt# x# 100000#) i#) ...
    
    into
    
        let lvl :: Int
            lvl = case remInt# x# 100000# of v { __DEFAULT__ -> I# v }
        in ... (-# (case lvl of { I# v -> v }) i#) ...
    
    But when, as in the example above, the expression that was floated out was
    the argument of an application, the resulting application may no longer
    satisfy the let/app invariant, because exprOkForSpeculation doesn't look
    far enough inside the definition of lvl.
    
    Solution: When the expression we floated out was okay for speculation, don't
    bother boxing it. It will be evaluated earlier, and that's okay by assumption.
    Fixes the let/app invariant and is cheaper too.
    
    Test Plan: make slowtest TEST=T13338
    
    Reviewers: austin, bgamari, simonpj
    
    Reviewed By: bgamari, simonpj
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D3217
    d0508ef0
SetLevels.hs 65.1 KB