diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2015-03-08 20:00:55 +0100 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2015-03-08 20:00:55 +0100 |
commit | 21d975a7d095b1a0c074396055ce9d23afd458bf (patch) | |
tree | 481db098195c7220b9d5e987647312b8d5166119 | |
parent | 1be0041bf81c0d7fcebf423097ff35b512f54e56 (diff) | |
download | haskell-21d975a7d095b1a0c074396055ce9d23afd458bf.tar.gz |
Fix two off-by-one errors
-rw-r--r-- | compiler/cmm/CmmSwitch.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/cmm/CmmSwitch.hs b/compiler/cmm/CmmSwitch.hs index 4bd905ed89..bbc1199b74 100644 --- a/compiler/cmm/CmmSwitch.hs +++ b/compiler/cmm/CmmSwitch.hs @@ -167,7 +167,7 @@ mkFlatSwitchPlan Nothing _ (m:ms) mkFlatSwitchPlan (Just l) r ms = let ((_,p1):ps) = go r ms in (p1, ps) where go (lo,hi) [] - | lo >= hi = [] + | lo > hi = [] | otherwise = [(lo, Unconditionally l)] go (lo,hi) (m:ms) | lo < min @@ -223,12 +223,11 @@ addRange (SwitchTargets Nothing Nothing m) = ((lo,hi), m, id) where (lo,_) = M.findMin m (hi,_) = M.findMax m --- No range, but a default. Make set the range, but also return the necessary --- branching +-- No range, but a default. Create a range, but also emit SwitchPlans for outside the range addRange (SwitchTargets Nothing (Just l) m) = ( (lo,hi) , m - , \plan -> (Unconditionally l, lo) `consSL` plan `snocSL` (hi, Unconditionally l) + , \plan -> (Unconditionally l, lo) `consSL` plan `snocSL` (hi+1, Unconditionally l) ) where (lo,_) = M.findMin m (hi,_) = M.findMax m |