-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement loop peeling. #1510
Implement loop peeling. #1510
Conversation
On a fresh clone (and even if I merge in
|
We will need at least one (and preferably more) C tests for this: they don't necessarily have to be super-super complex, but we should at least check that |
Right, so just the missing C tests left I think. |
I've just added one simple test. I'm currently trying to make a C tests where we can see constant forwarding into the body, but I haven't had any luck so far. |
I think |
I tried all the promote tests. But it seems because we are using NOOPT_VAL they are always loaded from the stack and thus not passed into the body. |
f: &F, | ||
) -> Result<Self, CompilationError> | ||
where | ||
F: Fn(InstIdx, &Module) -> Operand, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed: this should be (&Module, InstIdx)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inst::Tombstone => Inst::Tombstone, | ||
Inst::TraceHeaderStart => { | ||
// Copy the header label into the body while remapping the operands. | ||
m.trace_body_start = m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost certainly unsafe (similarly for TraceHeaderEnd
below): it means that calling this method permanently mutates the global notion of TraceHeaderStart
. If you call this method twice with a TraceHeaderStart
, weird things are likely to happen.
IMHO: either users are forbidden from calling this function with TraceHeaderStart | TraceHeaderEnd
or we work out some way of not mutating things globally.
Please squash. |
7aeae43
to
3f0c7a8
Compare
Squashed and rebased. |
Co-authored-by: Laurence Tratt <laurie@tratt.net>
3f0c7a8
to
3dfe285
Compare
This implements a basic version of loop peeling. Note, that additional optimisations based on loop peeling, like common subexpression eliminiation, are not included in this PR. Those will be implemented in subsequent PRs.