Skip to content

Implement Integer funnel shifts - #145690

Merged
bors merged 1 commit into
rust-lang:masterfrom
sayantn:integer-funnel-shift
Sep 4, 2025
Merged

Implement Integer funnel shifts#145690
bors merged 1 commit into
rust-lang:masterfrom
sayantn:integer-funnel-shift

Conversation

@sayantn

@sayantnsayantn commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

Tracking issue: #145686
ACP: rust-lang/libs-team#642

This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else

Thanks @folkertdev for the fixes and tests

cc @rust-lang/libs-api

@rustbot

Copy link
Copy Markdown
Collaborator

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbotrustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 20, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rust-log-analyzer

This comment has been minimized.

Comment threadlibrary/core/src/intrinsics/mod.rs Outdated
Comment threadcompiler/rustc_codegen_llvm/src/intrinsic.rs Outdated
Comment threadlibrary/core/src/num/uint_macros.rs Outdated
Comment threadlibrary/core/src/num/uint_macros.rs Outdated
Comment threadlibrary/core/src/intrinsics/mod.rs Outdated
Comment threadcompiler/rustc_const_eval/src/interpret/intrinsics.rs Outdated
Comment threadcompiler/rustc_const_eval/src/interpret/intrinsics.rs Outdated
Comment threadcompiler/rustc_const_eval/src/interpret/intrinsics.rs Outdated
@tgross35

Copy link
Copy Markdown
Member

I see there is a tracking issue, but not an ACP for this. Could you create one? It's an issue template at https://github.com/rust-lang/libs-team/issues.

Comment threadlibrary/core/src/intrinsics/mod.rs
@rustbot

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@sayantn
sayantnforce-pushed the integer-funnel-shift branch from b91850b to 400a29dCompareAugust 22, 2025 16:30
@rust-log-analyzer

This comment has been minimized.

@sayantn
sayantnforce-pushed the integer-funnel-shift branch from 400a29d to 23601d2CompareAugust 22, 2025 16:37
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-log-analyzer

This comment has been minimized.

@tgross35tgross35 added S-waiting-on-team and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 27, 2025
Comment threadcompiler/rustc_codegen_cranelift/src/intrinsics/mod.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@sayantn
sayantnforce-pushed the integer-funnel-shift branch from 5f4c412 to 63fde15CompareAugust 28, 2025 01:39

@tgross35tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few tiny requests from me then I think this looks good, as long as @RalfJung doesn't have anything else.

Per usual, please squash. You can also (optionally) drop the CABs from the commit messages assuming they come from the GH suggestion, as typically review feedback is given without need for authorship attribution - bit misleading that GH adds these automatically for what are usually typo fixes (unless @folkertdev authored more of this patch then I'm realizing 🙂)

View changes since this review

Comment threadlibrary/core/src/intrinsics/fallback.rs Outdated
Comment threadlibrary/core/src/intrinsics/fallback.rs Outdated
Comment threadlibrary/core/src/intrinsics/fallback.rs Outdated
Comment threadlibrary/coretests/tests/num/uint_macros.rs
@tgross35tgross35 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 3, 2025
@sayantn

Copy link
Copy Markdown
ContributorAuthor

@folkertdev did author a significant part of the patches, including the tests and (although removed now) gcc, clif and const-eval implementations. Also, is a squash really needed, I believe the current commit structure is helpful for reviewers as it clearly separates the different objectives (libs impl, cg_llvm and tests)

@tgross35

tgross35 commented Sep 3, 2025

Copy link
Copy Markdown
Member

@folkertdev did author a significant part of the patches, including the tests and (although removed now) gcc, clif and const-eval implementations.

I didn't have this context, makes sense 👍 thanks for including in that case

Also, is a squash really needed, I believe the current commit structure is helpful for reviewers as it clearly separates the different objectives (libs impl, cg_llvm and tests)

If it's not a big number of tests then it's always good to have them in the same commit as whatever enables / fixes them, so you can look at a single point in history and see "x changed and produced y visible results" (tests are already separated enough by file/directory). So ideally I'd suggest reordering from current commits 1,2,3 to 2,squash(1,3), which also avoids the fact that adding library support before compiler support just crashes (using the pedantic repo's litmus test of what happens if git bisect happens to drop you between two commits and try to run tests - yes, not super relevant for our repo because bisect has --first-parent).

But we don't have strict history requirements, so I ofc won't insist on that. At a minimum though, please update the commit message "Add tests" to at least specify what tests; that's never the most insightful message to see in the log :)

@sayantn

Copy link
Copy Markdown
ContributorAuthor

Makes sense, I'd just squash the commits (lazy lol)

 - Add a fallback implementation for the intrinsics
- Add LLVM backend support for funnel shifts
Co-Authored-By: folkertdev <folkert@folkertdev.nl>
@sayantn
sayantnforce-pushed the integer-funnel-shift branch from c1260ef to 62b4347CompareSeptember 3, 2025 08:44

@tgross35tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! r=me after CI passes

View changes since this review

@sayantn

Copy link
Copy Markdown
ContributorAuthor

@bors r=tgross35

@bors

bors commented Sep 4, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 62b4347 has been approved by tgross35

It is now in the queue for this repository.

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 4, 2025
@jhprattjhpratt mentioned this pull request Sep 4, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 4, 2025
…ross35
Implement Integer funnel shifts
Tracking issue: rust-lang#145686
ACP: rust-lang/libs-team#642
This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else
Thanks ``@folkertdev`` for the fixes and tests
cc ``@rust-lang/libs-api``
@ZalatharZalathar mentioned this pull request Sep 4, 2025
bors added a commit that referenced this pull request Sep 4, 2025
Rollup of 5 pull requests
Successful merges:
- #145682 (Promote aarch64-pc-windows-msvc to Tier 1)
- #145690 (Implement Integer funnel shifts)
- #146119 (compiletest: Implement an experimental `--new-output-capture` mode)
- #146168 (Update bootstrap's dependencies to remove winapi and old windows-sys)
- #146182 (Don't require next-solver `ProbeRef` to be `Copy`)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 00d5dc5 into rust-lang:masterSep 4, 2025
10 checks passed
@rustbotrustbot added this to the 1.91.0 milestone Sep 4, 2025
rust-timer added a commit that referenced this pull request Sep 4, 2025
Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35
Implement Integer funnel shifts
Tracking issue: #145686
ACP: rust-lang/libs-team#642
This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else
Thanks `@folkertdev` for the fixes and tests
cc `@rust-lang/libs-api`
@bors

bors commented Sep 4, 2025

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 62b4347 with merge 45b9d13...

@tgross35

Copy link
Copy Markdown
Member

@bors r-
Why does it keep doing that...

@sayantn
sayantn deleted the integer-funnel-shift branch September 4, 2025 20:46
github-actionsBot pushed a commit to rust-lang/miri that referenced this pull request Sep 5, 2025
Rollup of 5 pull requests
Successful merges:
- rust-lang/rust#145682 (Promote aarch64-pc-windows-msvc to Tier 1)
- rust-lang/rust#145690 (Implement Integer funnel shifts)
- rust-lang/rust#146119 (compiletest: Implement an experimental `--new-output-capture` mode)
- rust-lang/rust#146168 (Update bootstrap's dependencies to remove winapi and old windows-sys)
- rust-lang/rust#146182 (Don't require next-solver `ProbeRef` to be `Copy`)
r? `@ghost`
`@rustbot` modify labels: rollup
@Zalathar

Copy link
Copy Markdown
Member

Bors, please, it's already merged.

@bors r- retry

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 5, 2025
github-actionsBot pushed a commit to model-checking/verify-rust-std that referenced this pull request Sep 9, 2025
…ross35
Implement Integer funnel shifts
Tracking issue: rust-lang#145686
ACP: rust-lang/libs-team#642
This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else
Thanks `@folkertdev` for the fixes and tests
cc `@rust-lang/libs-api`
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@sayantn@rustbot@rust-log-analyzer@tgross35@bjorn3@clarfonthey@bors@Zalathar@RalfJung@programmerjake@folkertdev@scottmcm