Commit 44d4bf2c authored by simonpj@microsoft.com's avatar simonpj@microsoft.com

Add -fspec-inline-join-points to SpecConstr

This patch addresses a problem that Roman found in SpecConstr.  Consider:

foo :: Maybe Int -> Maybe Int -> Int
foo a b = let j b = foo a b
           in
           case b of
             Nothing -> ...
             Just n  -> case a of
                          Just m  -> ... j (Just (n+1)) ...
                          Nothing -> ... j (Just (n-1)) ...

We want to make specialised versions for 'foo' for the patterns
	Nothing  (Just v)
	(Just a) (Just b)

Two problems, caused by the join point j.  First, j does not
scrutinise b, so j won't be specialised f for the (Just v) pattern.
Second, j is defined where the free var 'a' is not evaluated.

Both are solved by brutally inlining j at its call sites.  This risks
major code bloat, but it's relatively quick to implement.  The flag
	-fspec-inline-join-points
causes brutal inlining for a 
	non-recursive binding
	of a function
	whose RHS contains calls
	of a recursive function

The (experimental) flag is static for now, and I have not even
documented it properly.
parent 448873c0
......@@ -49,6 +49,7 @@ module StaticFlags (
-- optimisation opts
opt_NoMethodSharing,
opt_NoStateHack,
opt_SpecInlineJoinPoints,
opt_CprOff,
opt_SimplNoPreInlining,
opt_SimplExcessPrecision,
......@@ -303,6 +304,7 @@ opt_Parallel = lookUp FSLIT("-fparallel")
opt_Flatten = lookUp FSLIT("-fflatten")
-- optimisation opts
opt_SpecInlineJoinPoints = lookUp FSLIT("-fspec-inline-join-points")
opt_NoStateHack = lookUp FSLIT("-fno-state-hack")
opt_NoMethodSharing = lookUp FSLIT("-fno-method-sharing")
opt_CprOff = lookUp FSLIT("-fcpr-off")
......@@ -362,6 +364,7 @@ isStaticFlag f =
"fauto-sccs-on-individual-cafs",
"fscc-profiling",
"fdicts-strict",
"fspec-inline-join-points",
"firrefutable-tuples",
"fparallel",
"fflatten",
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment