Skip to content
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

Tweak compiler strategies #166

Merged
merged 3 commits into from
May 3, 2024

Conversation

countvajhula
Copy link
Collaborator

Summary of Changes

Tweak some strategies as discussed in the past:

  • avoid premature termination of source syntax in applying optimizations (i.e. one specific case)
  • optimize to fixed point in deforestation too (in addition to normalization)

Public Domain Dedication

  • In contributing, I relinquish any copyright claims on my contribution and freely release it into the public domain in the simple hope that it will provide value.

(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)

In traversing the source syntax to apply rewrite rules in the
compiler, we formerly would stop traversing a branch at a node (while
continuing to explore other nodes) if the rule was successfully
applied to that node. But there are cases where the same rewrite rule
would apply at multiple levels of the same syntax node. In such cases,
we would only rewrite (e.g. optimize) the highest level node where it
applies, leaving the others unchanged, which could mean missed
optimizations.

Of the three former termination conditions:

(1) transforming function returns false
(2) leaf node is encountered
(3) transformation is successful

… we now only retain the former two, to ensure that the tree is fully
traversed in applying rewrite rules.

Fixes drym-org#154.
In last week's meeting we realized this was necessary, but I can't
recall an example now of where it's needed.
This records the testcase but we don't yet have a good way to test
what we are looking for here.
@countvajhula countvajhula marked this pull request as ready for review May 3, 2024 19:03
@countvajhula
Copy link
Collaborator Author

@dzoep reviewed during the Qi meeting.

@countvajhula countvajhula merged commit a1ae91e into drym-org:main May 3, 2024
5 of 6 checks passed
@countvajhula countvajhula deleted the tweak-compiler-strategies branch May 3, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant