Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimize divisions and remainders by constants.#5167

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sjrd wants to merge1 commit intoscala-js:main
base:main
Choose a base branch
Loading
fromsjrd:opt-divide-and-remainder

Conversation

sjrd
Copy link
Member

@sjrdsjrd commentedMay 10, 2025
edited
Loading

Following the techniques described in Hacker's Delight, Chapter 10.

Benchmarking suggested that is this generally worth it, except for non-powers of 2 for a) int operations on JS and b) long operations on Wasm.

For the long divisions on JS, this yields a 6x speedup, despite the fact that the resulting code needs 16 (!) primitive int multiplications.

plokhotnyuk and He-Pin reacted with rocket emoji
@sjrdsjrdforce-pushed theopt-divide-and-remainder branch 2 times, most recently fromb0ca504 to0ef8849CompareJune 2, 2025 15:34
@sjrdsjrdforce-pushed theopt-divide-and-remainder branch from0ef8849 to560a48cCompareJune 13, 2025 16:38
@sjrdsjrdforce-pushed theopt-divide-and-remainder branch 3 times, most recently fromeee96e7 to864ebaeCompareJune 23, 2025 15:23
@sjrdsjrdforce-pushed theopt-divide-and-remainder branch 4 times, most recently from3eac5c3 to615ec6aCompareJuly 15, 2025 15:24
@sjrdsjrd marked this pull request as ready for reviewJuly 15, 2025 15:25
@sjrdsjrd requested a review fromgzm0July 15, 2025 15:25
@sjrd
Copy link
MemberAuthor

@gzm0 This PR is now ready for review. It sent me through many detours before I could finish it. :p

@sjrdsjrdforce-pushed theopt-divide-and-remainder branch 3 times, most recently from1d6ce9e to95a590fCompareJuly 15, 2025 16:27
Following the techniques described in Hacker's Delight, Chapter 10.Benchmarking suggested that is this generally worth it, except fornon-powers of 2 for a) int operations on JS and b) long operationson Wasm.For the long divisions on JS, this yields a 6x speedup, despite thefact that the resulting code needs 16 (!) primitive intmultiplications.
@sjrdsjrdforce-pushed theopt-divide-and-remainder branch from95a590f tobe78b6aCompareJuly 15, 2025 16:43
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gzm0gzm0Awaiting requested review from gzm0

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@sjrd

[8]ページ先頭

©2009-2025 Movatter.jp