Skip to content

Prototype loop unrolling hint attributes#156816

Draft
saethlin wants to merge 2 commits into
rust-lang:mainfrom
saethlin:loop-attributes
Draft

Prototype loop unrolling hint attributes#156816
saethlin wants to merge 2 commits into
rust-lang:mainfrom
saethlin:loop-attributes

Conversation

@saethlin
Copy link
Copy Markdown
Member

@saethlin saethlin commented May 22, 2026

Tracking issue: #156874

This adds as new attribute #[unroll]/#[unroll(always)]/#[unroll(never)]/#[unroll(16)] (or any u32).

#[unroll] is behind a new feature gate #![feature(loop_hints)] because I intend to add an attribute for loop vectorization as well. If a user wants to turn off loop unrolling to locally minimize code size, LLVM may vectorize the loop even though it isn't unrolled which can produce a similar code size explosion.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@saethlin saethlin force-pushed the loop-attributes branch 2 times, most recently from 9c8f21c to 22381f6 Compare May 24, 2026 21:15
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 30, 2026

☔ The latest upstream changes (presumably #157149) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants