diff options
| -rw-r--r-- | compiler/cmm/CmmSwitch.hs | 15 | ||||
| -rw-r--r-- | testsuite/tests/perf/compiler/all.T | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/compiler/cmm/CmmSwitch.hs b/compiler/cmm/CmmSwitch.hs index 09abec6f8b..604e759208 100644 --- a/compiler/cmm/CmmSwitch.hs +++ b/compiler/cmm/CmmSwitch.hs @@ -258,12 +258,23 @@ targetSupportsSwitch _ = False -- | This function creates a SwitchPlan from a SwitchTargets value, breaking it -- down into smaller pieces suitable for code generation. createSwitchPlan :: SwitchTargets -> SwitchPlan -createSwitchPlan (SwitchTargets signed mbdef range m) = +-- Lets do the common case of a singleton map quicky and efficiently (#10677) +createSwitchPlan (SwitchTargets _signed _range (Just defLabel) m) + | [(x, l)] <- M.toList m + = IfEqual x l (Unconditionally defLabel) +-- And another common case, matching booleans +createSwitchPlan (SwitchTargets _signed (lo,hi) Nothing m) + | [(x1, l1), (x2,l2)] <- M.toAscList m + , x1 == lo + , x2 == hi + , x1 + 1 == x2 + = IfEqual x1 l1 (Unconditionally l2) +createSwitchPlan (SwitchTargets signed range mbdef m) = -- pprTrace "createSwitchPlan" (text (show ids) $$ text (show (range,m)) $$ text (show pieces) $$ text (show flatPlan) $$ text (show plan)) $ plan where pieces = concatMap breakTooSmall $ splitAtHoles maxJumpTableHole m - flatPlan = findSingleValues $ mkFlatSwitchPlan signed range mbdef pieces + flatPlan = findSingleValues $ mkFlatSwitchPlan signed mbdef range pieces plan = buildTree signed $ flatPlan diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T index 66b13bdacb..affc2671a8 100644 --- a/testsuite/tests/perf/compiler/all.T +++ b/testsuite/tests/perf/compiler/all.T @@ -416,7 +416,7 @@ test('T783', # 2014-09-03: 223377364 (Windows) better specialisation, raft of core-to-core optimisations # 2014-12-22: 235002220 (Windows) not sure why - (wordsize(64), 548288760, 10)]), + (wordsize(64), 470738808, 10)]), # prev: 349263216 (amd64/Linux) # 07/08/2012: 384479856 (amd64/Linux) # 29/08/2012: 436927840 (amd64/Linux) @@ -437,6 +437,8 @@ test('T783', # this test seems to be an extreme outlier.) # 2015-05-16: 548288760 (amd64/Linux) # (improved sequenceBlocks in nativeCodeGen, #10422) + # 2015-08-07: 470738808 (amd64/Linux) + # (simplifying the switch plan code path for simple checks, #10677) extra_hc_opts('-static') ], compile,['']) |
