Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex D
GHC
Commits
04b17d61
Commit
04b17d61
authored
Nov 17, 2010
by
simonpj@microsoft.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments only
parent
4cfb18e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
7 deletions
+26
-7
compiler/specialise/SpecConstr.lhs
compiler/specialise/SpecConstr.lhs
+26
-7
No files found.
compiler/specialise/SpecConstr.lhs
View file @
04b17d61
...
...
@@ -421,16 +421,22 @@ loop. Here is a (simplified) example from the vector library:
{-# INLINE foldl #-}
foldl f z (Stream step s _) = foldl_loop SPEC z s
where
foldl_loop
S
PEC z s = case step s of
Yield x s' -> foldl_loop
S
PEC (f z x) s'
Skip -> foldl_loop
S
PEC z s'
foldl_loop
!s
PEC z s = case step s of
Yield x s' -> foldl_loop
s
PEC (f z x) s'
Skip -> foldl_loop
s
PEC z s'
Done -> z
SpecConstr will spot the SPEC parameter and always fully specialise
foldl_loop. Note that we can't just annotate foldl_loop since it isn't a
top-level function but even if we could, inlining etc. could easily drop the
annotation. We also have to prevent the SPEC argument from being removed by
w/w which is why SPEC is a sum type. This is all quite ugly; we ought to come
foldl_loop. Note that
* We have to prevent the SPEC argument from being removed by
w/w which is why (a) SPEC is a sum type, and (b) we have to seq on
the SPEC argument.
* And lastly, the SPEC argument is ultimately eliminated by
SpecConstr itself so there is no runtime overhead.
This is all quite ugly; we ought to come
up with a better design.
ForceSpecConstr arguments are spotted in scExpr' and scTopBinds which then set
...
...
@@ -438,6 +444,19 @@ force_spec to True when calling specLoop. This flag makes specLoop and
specialise ignore specConstrCount and specConstrThreshold when deciding
whether to specialise a function.
What alternatives did I consider? Annotating the loop itself doesn't
work because (a) it is local and (b) it will be w/w'ed and I having
w/w propagating annotation somehow doesn't seem like a good idea. The
types of the loop arguments really seem to be the most persistent
thing.
Annotating the types that make up the loop state s doesn't work,
either, because (a) it would prevent us from using types like Either
or tuples here, (b) we don't want to restrict the set of types that
can be used in Stream states and (c) some types are fixed by the user
(e.g., the accumulator here) but we still want to specialise as much
as possible.
-----------------------------------------------------
Stuff not yet handled
-----------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment