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

llvm: convert @divFloor and @mod to forms llvm will recognize #22540

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

jacobly0
Copy link
Member

On x86_64, the @divFloor change is a strict improvement, and the @mod change adds one zero latency instruction. In return, once we upgrade to LLVM 20, when the optimizer discovers one of these operations has a power-of-two constant rhs, it will be able to optimize the entire operation into an ashr or and, respectively.

                  #I   CPL   CPT
old `@divFloor` |  8 | 15 | .143 |
new `@divFloor` |  7 | 15 | .148 |
old `@mod`      |  9 | 17 | .134 | (rip llvm
new `@mod`      | 10 | 17 | .138 |  scheduler)

On x86_64, the `@divFloor` change is a strict improvement, and the
`@mod` change adds one zero latency instruction.  In return, once we
upgrade to LLVM 20, when the optimizer discovers one of these operations
has a power-of-two constant rhs, it will be able to optimize the entire
operation into an `ashr` or `and`, respectively.

                      #I   CPL   CPT
    old `@divFloor` |  8 | 15 | .143 |
    new `@divFloor` |  7 | 15 | .148 |
    old `@mod`      |  9 | 17 | .134 | (rip llvm
    new `@mod`      | 10 | 17 | .138 |  scheduler)
@andrewrk andrewrk enabled auto-merge (rebase) January 19, 2025 02:01
@andrewrk andrewrk merged commit 5cfcb01 into ziglang:master Jan 20, 2025
10 checks passed
@jacobly0 jacobly0 deleted the llvm-div-floor branch January 20, 2025 05:19
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.

2 participants