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

Use LLVM intrinsics for saturating add/sub #58003

Merged
merged 1 commit into from
Jan 31, 2019
Merged

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Jan 30, 2019

Use the [su](add|sub).sat LLVM intrinsics, if we're compiling against LLVM 8, as they should optimize and codegen better than IR based on [su](add|sub).with.overlow.

For the fallback for LLVM < 8 I'm using the same expansion that target lowering in LLVM uses, which is not the same as Rust currently uses (in particular due to the use of selects rather than branches).

Fixes #55286.
Fixes #52203.
Fixes #44500.

r? @nagisa

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 30, 2019
@nagisa
Copy link
Member

nagisa commented Jan 30, 2019

The PR looks good, although I think I’d like a codegen test, especially for our own lowering. Alas we do not have max-llvm-version filter for tests :(

@bors r+

@bors
Copy link
Contributor

bors commented Jan 30, 2019

📌 Commit 4a4186e has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2019
@bors
Copy link
Contributor

bors commented Jan 30, 2019

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jan 30, 2019

📌 Commit 4a4186e has been approved by nagisa

@nagisa
Copy link
Member

nagisa commented Jan 30, 2019

Oh, and recalling one such similar PR, we had a fairly big perf. regression there: #56009. I wonder how this will fare...

@bors
Copy link
Contributor

bors commented Jan 31, 2019

⌛ Testing commit 4a4186e with merge fc11513df6d91f6c2ea34c7e77844ed503e04d4d...

@bors
Copy link
Contributor

bors commented Jan 31, 2019

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 31, 2019
@nikic
Copy link
Contributor Author

nikic commented Jan 31, 2019

@bors retry

Failure looks spurious.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 31, 2019
@bors
Copy link
Contributor

bors commented Jan 31, 2019

⌛ Testing commit 4a4186e with merge 8a0e5fa...

bors added a commit that referenced this pull request Jan 31, 2019
Use LLVM intrinsics for saturating add/sub

Use the `[su](add|sub).sat` LLVM intrinsics, if we're compiling against LLVM 8, as they should optimize and codegen better than IR based on `[su](add|sub).with.overlow`.

For the fallback for LLVM < 8 I'm using the same expansion that target lowering in LLVM uses, which is not the same as Rust currently uses (in particular due to the use of selects rather than branches).

Fixes #55286.
Fixes #52203.
Fixes #44500.

r? @nagisa
@bors
Copy link
Contributor

bors commented Jan 31, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: nagisa
Pushing 8a0e5fa to master...

@bors bors merged commit 4a4186e into rust-lang:master Jan 31, 2019
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #58003!

Tested on commit 8a0e5fa.
Direct link to PR: #58003

💔 miri on windows: test-pass → test-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).
💔 miri on linux: test-pass → test-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jan 31, 2019
Tested on commit rust-lang/rust@8a0e5fa.
Direct link to PR: <rust-lang/rust#58003>

💔 miri on windows: test-pass → test-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).
💔 miri on linux: test-pass → test-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).
@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 7, 2019

You can use llvm.sadd.sat on any integer bit width or vectors of integers.

Cool, these also should work on vector types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants