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

Add add1, sub1 and abs to cptypes #790

Merged
merged 5 commits into from
Jan 10, 2024
Merged

Add add1, sub1 and abs to cptypes #790

merged 5 commits into from
Jan 10, 2024

Conversation

gus-massa
Copy link
Contributor

Add special cases for add1, sub1 and abs to cptypes. In particular, that they are closed for flonums, reals and exact-integers.

@jltaylor-us
Copy link
Contributor

needs more mats to cover all of the clauses in the new specializations

@gus-massa
Copy link
Contributor Author

I added more tests.

@jltaylor-us
Copy link
Contributor

Still doesn't test the bignum case for abs, but looks ok to me. I don't think I've actually done any work in cptypes before, though, so maybe one of the other maintainers will give it a quick glance before it goes in.

@mflatt
Copy link
Contributor

mflatt commented Jan 9, 2024

The changes in cptypes.ss look good to me. I agree that it would be good to cover the bignum case of abs with a test (which is the one where I had to pause to believe that it's right).

@gus-massa
Copy link
Contributor Author

I don't care too much about bignums because they don't trigger too many optimizations. I care more about fixnums.

A long time ago, I added bignums so (and (integer? x) (exact? x)) is equivalent to (or (fixnum? x) (bignum? x)). This is a reduction in cpnanopass that is not visible by cptypes, but the reduction may be moved to an early pass in the future, or the expression may be in the code written by the programmer.

Now, I added the test for bignums in abs and also negative tests in the others. I also added the negative tests for fixnums. They are sanity checks, because it's too easy to be confused and add a wrong rule for fixnums in the future to cptypes.

@mflatt mflatt merged commit 0ea1ff3 into cisco:main Jan 10, 2024
13 checks passed
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.

3 participants