diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-10-18 14:35:07 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-10-18 14:35:07 +0100 |
commit | 41212fd652b59d949a993225e90cb202f2a33087 (patch) | |
tree | 815af392e08459bea083ef761dd36d9fe0f69b9a /compiler/cmm/CmmLayoutStack.hs | |
parent | d43bf5d8f8474724faba818627e7e3b920bcdb2e (diff) | |
download | haskell-41212fd652b59d949a993225e90cb202f2a33087.tar.gz |
Clarify comments and liberalise stack-check optimisation slightly
The only substantive change here is to change "==" into ">=" in
the Note [Always false stack check] code. This is semantically
correct, but won't have any practical impact.
Diffstat (limited to 'compiler/cmm/CmmLayoutStack.hs')
-rw-r--r-- | compiler/cmm/CmmLayoutStack.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/cmm/CmmLayoutStack.hs b/compiler/cmm/CmmLayoutStack.hs index 2efb806a1e..23da5d02cd 100644 --- a/compiler/cmm/CmmLayoutStack.hs +++ b/compiler/cmm/CmmLayoutStack.hs @@ -775,23 +775,24 @@ areaToSp dflags sp_old _sp_hwm area_off (CmmStackSlot area n) = areaToSp dflags _ sp_hwm _ (CmmLit CmmHighStackMark) = mkIntExpr dflags sp_hwm areaToSp dflags _ _ _ (CmmMachOp (MO_U_Lt _) -- Note [Always false stack check] [CmmMachOp (MO_Sub _) - [ CmmRegOff (CmmGlobal Sp) off - , CmmLit (CmmInt lit _)], + [ CmmRegOff (CmmGlobal Sp) x_off + , CmmLit (CmmInt y_lit _)], CmmReg (CmmGlobal SpLim)]) - | fromIntegral off == lit = zeroExpr dflags + | fromIntegral x_off >= y_lit = zeroExpr dflags areaToSp _ _ _ _ other = other -- Note [Always false stack check] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- -- We can optimise stack checks of the form -- --- if ((Sp + x) - x < SpLim) then .. else .. +-- if ((Sp + x) - y < SpLim) then .. else .. -- --- where x is an integer offset. Optimising this away depends on knowing that --- SpLim <= Sp, so it is really the job of the stack layout algorithm, hence we --- do it now. This is also convenient because sinking pass will later drop the --- dead code. +-- where are non-negative integer byte offsets. Since we know that +-- SpLim <= Sp (remember the stack grows downwards), this test must +-- yield False if (x >= y), so we can rewrite the comparison to False. +-- A subsequent sinking pass will later drop the dead code. +-- Optimising this away depends on knowing that SpLim <= Sp, so it is +-- really the job of the stack layout algorithm, hence we do it now. optStackCheck :: CmmNode O C -> CmmNode O C optStackCheck n = -- Note [null stack check] |