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

Shift and Add multiplication for constants #36

Closed
dakk opened this issue Mar 28, 2024 · 0 comments · Fixed by #41
Closed

Shift and Add multiplication for constants #36

dakk opened this issue Mar 28, 2024 · 0 comments · Fixed by #41
Labels
enhancement New feature or request optimization Compiler optimization typing Typing related

Comments

@dakk
Copy link
Owner

dakk commented Mar 28, 2024

When we have bin operations with a constant operator, it is sometime possible to do some optimization.

For instance if we want to multiply and diving two numbers, and one operand is a constant, we can achieve it using shift and add multiplication algorithm (https://youtu.be/acUH4lWe2NQ?si=H7GAS241CZuyBe3C&t=880)

We need to refactor the type abastraction in order to have mul (a times b) and mul_c (a times Const), etc; or we can extend mul() to handle different case; or we can call simplify logic directly in operations.

We need a Qtype.is_const #37 to check if a Qtype is constant (only contains False/True).

@dakk dakk added enhancement New feature or request optimization Compiler optimization typing Typing related labels Mar 28, 2024
@dakk dakk mentioned this issue Mar 28, 2024
5 tasks
@dakk dakk changed the title Optimize binop with constant operand Shift and Add multiplication for constants Apr 12, 2024
@dakk dakk linked a pull request Apr 16, 2024 that will close this issue
@dakk dakk closed this as completed in #41 Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization Compiler optimization typing Typing related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant