Skip to content

Conversation

@davidtwco
Copy link
Member

@davidtwco davidtwco commented Jul 14, 2025

Supercedes #118917.

Initial experimental implementation of rust-lang/rfcs#3838. Introduces a rustc_scalable_vector(N) attribute that can be applied to types with a single [$ty] field (for u{16,32,64}, i{16,32,64}, f{32,64}, bool). rustc_scalable_vector types are lowered to scalable vectors in the codegen backend.

As with any unstable feature, there will necessarily be follow-ups as we experiment and find cases that we've not considered or still need some logic to handle, but this aims to be a decent baseline to start from.

See #145052 for request for a lang experiment.

@rustbot
Copy link
Collaborator

rustbot commented Jul 14, 2025

r? @compiler-errors

rustbot has assigned @compiler-errors.
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

@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-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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 14, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

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 platform-builtins intrinsics. Make sure the
LLVM backend as well as portable-simd gets adapted for the changes.

cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

changes to the core type system

cc @compiler-errors, @lcnr

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@davidtwco davidtwco marked this pull request as draft July 14, 2025 11:21
@rustbot rustbot 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 Jul 14, 2025
@davidtwco
Copy link
Member Author

I've changed this back to a draft and marked it as S-waiting-on-author while I rebase it and get the approval for an experimental implementation to go ahead.

@davidtwco davidtwco force-pushed the sve-infrastructure branch 2 times, most recently from cf9474d to d58c634 Compare July 14, 2025 11:53
@rust-log-analyzer

This comment was marked as resolved.

@davidtwco davidtwco force-pushed the sve-infrastructure branch 2 times, most recently from 0c22701 to 3ad0898 Compare July 14, 2025 12:12
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@davidtwco davidtwco force-pushed the sve-infrastructure branch from 5c92874 to 3edf1b6 Compare July 14, 2025 13:30
@rust-log-analyzer

This comment has been minimized.

@davidtwco davidtwco force-pushed the sve-infrastructure branch from 3edf1b6 to 4f6b823 Compare July 14, 2025 14:20
Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

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

I do not intend to have repr(simd) survive this year, so I do not think this should be added.

@davidtwco
Copy link
Member Author

I do not intend to have repr(simd) survive this year, so I do not think this should be added.

Could you elaborate?

@workingjubilee
Copy link
Member

I intend to replace it with an approach based on lang items for a variety of reasons, one of them being that to start with, the repr(simd) "attribute" does not compose and should not.

r? @workingjubilee

@workingjubilee

This comment was marked as outdated.

@workingjubilee
Copy link
Member

That last scan-through should be all, unless something is revealed (made apparent?) by the next iteration, so

@rustbot author

@rustbot rustbot 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 Dec 10, 2025
@bors

This comment was marked as resolved.

@workingjubilee
Copy link
Member

Seems good to me, r=me with rebase.

davidtwco and others added 7 commits December 16, 2025 11:00
Extend parsing of `ReprOptions` with `rustc_scalable_vector(N)` which
optionally accepts a single literal integral value - the base multiple of
lanes that are in a scalable vector. Can only be applied to structs.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
Extend well-formedness checking and HIR analysis to prohibit the use of
scalable vectors in structs, enums, unions, tuples and arrays. LLVM does
not support scalable vectors being members of other types, so these
restrictions are necessary.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
Introduces `BackendRepr::ScalableVector` corresponding to scalable
vector types annotated with `repr(scalable)` which lowers to a scalable
vector type in LLVM.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
LLVM doesn't handle stores on `<vscale x N x i1>` for `N != 16`, a type
used internally in SVE intrinsics. Spilling to the stack to create
debuginfo will cause errors during instruction selection. These types
that are an internal implementation detail to the intrinsic, so users
should never see them types and won't need any debuginfo.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
Scalable vectors cannot be members of ADTs and thus cannot be kept over
await points in async functions.
Scalable vector types only work with the relevant target features
enabled, so require this for any function with the types in its
signature.
The `fmt::Debug` impl for `TyAndLayout<'a, Ty>'` requires `fmt::Display`
on the `Ty` parameter. In `ArgAbi`, `TyAndLayout`'s Ty` is instantiated
with a parameter that implements `TyAbiInterface`. `TyAbiInterface`
only required `fmt::Debug` be implemented on `Self`, not `fmt::Display`,
which meant that it wasn't actually possible to debug print `ArgAbi`.
@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2025

This PR was rebased onto a different main 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.

@davidtwco
Copy link
Member Author

@bors r=workingjubilee

@bors
Copy link
Collaborator

bors commented Dec 16, 2025

📌 Commit f0dfeab has been approved by workingjubilee

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 16, 2025
@bors
Copy link
Collaborator

bors commented Dec 16, 2025

⌛ Testing commit f0dfeab with merge 95a27ad...

@bors
Copy link
Collaborator

bors commented Dec 16, 2025

☀️ Test successful - checks-actions
Approved by: workingjubilee
Pushing 95a27ad to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 16, 2025
@bors bors merged commit 95a27ad into rust-lang:main Dec 16, 2025
12 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 16, 2025
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 61cc47e (parent) -> 95a27ad (this PR)

Test differences

Show 224 test diffs

Stage 0

  • errors::verify_codegen_ssa_aarch64_softfloat_neon_126: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_aarch64_softfloat_neon_127: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_compiler_builtins_cannot_call_120: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_compiler_builtins_cannot_call_121: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_dynamic_linking_with_lto_135: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_error_calling_dlltool_119: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_error_creating_remark_dir_119: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_error_creating_remark_dir_120: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_error_writing_def_file_118: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_failed_to_get_layout_115: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_forbidden_ctarget_feature_130: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_forbidden_target_feature_attr_115: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_lto_disallowed_132: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_lto_dylib_132: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_lto_dylib_133: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_lto_proc_macro_133: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_target_feature_safe_trait_113: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_target_feature_safe_trait_114: [missing] -> pass (J2)
  • errors::verify_codegen_ssa_unknown_ctarget_feature_prefix_127: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_xcrun_failed_invoking_123: pass -> [missing] (J2)
  • errors::verify_codegen_ssa_xcrun_sdk_path_warning_125: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_as_needed_compatibility_59: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_as_needed_compatibility_60: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_doc_alias_malformed_62: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_doc_alias_malformed_63: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_empty_link_name_48: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_empty_link_name_49: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_import_name_type_raw_60: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_import_name_type_x86_56: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_import_name_type_x86_57: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_incompatible_wasm_link_50: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_incompatible_wasm_link_51: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_invalid_attr_unsafe_47: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_limit_invalid_61: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_limit_invalid_62: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_link_requires_name_51: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_link_requires_name_52: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_raw_dylib_only_windows_53: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_raw_dylib_only_windows_54: [missing] -> pass (J2)
  • session_diagnostics::verify_attr_parsing_suffixed_literal_in_attribute_47: pass -> [missing] (J2)
  • session_diagnostics::verify_attr_parsing_whole_archive_needs_static_59: [missing] -> pass (J2)

Stage 1

  • errors::verify_codegen_ssa_aarch64_softfloat_neon_126: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_aix_strip_not_used_123: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_compiler_builtins_cannot_call_120: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_dlltool_fail_import_library_117: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_dynamic_linking_with_lto_134: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_dynamic_linking_with_lto_135: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_error_creating_import_library_122: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_error_creating_remark_dir_119: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_error_writing_def_file_118: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_feature_not_valid_130: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_feature_not_valid_131: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_forbidden_ctarget_feature_129: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_forbidden_ctarget_feature_130: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_forbidden_target_feature_attr_115: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_invalid_monomorphization_non_scalable_type_113: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_lto_disallowed_131: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_lto_dylib_133: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_target_feature_safe_trait_113: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_unknown_ctarget_feature_prefix_128: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_xcrun_failed_invoking_124: [missing] -> pass (J1)
  • errors::verify_codegen_ssa_xcrun_sdk_path_warning_125: pass -> [missing] (J1)
  • errors::verify_codegen_ssa_xcrun_unsuccessful_124: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_as_needed_compatibility_59: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_bundle_needs_static_57: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_empty_link_name_48: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_empty_link_name_49: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_import_name_type_raw_60: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_import_name_type_x86_56: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_import_name_type_x86_57: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_invalid_attr_unsafe_46: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_invalid_link_modifier_54: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_limit_invalid_61: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_limit_invalid_62: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_link_framework_apple_50: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_multiple_modifiers_55: pass -> [missing] (J1)
  • session_diagnostics::verify_attr_parsing_raw_dylib_no_nul_53: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_raw_dylib_only_windows_54: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_rustc_scalable_vector_count_out_of_range_46: [missing] -> pass (J1)
  • session_diagnostics::verify_attr_parsing_whole_archive_needs_static_59: [missing] -> pass (J1)
  • [ui] tests/ui/scalable-vectors/closure-capture.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J2)
  • [ui] tests/ui/scalable-vectors/fn-trait.rs: [missing] -> pass (J2)
  • [ui] tests/ui/scalable-vectors/illformed-element-type.rs: [missing] -> pass (J2)
  • [ui] tests/ui/scalable-vectors/illformed-tuples-of-scalable-vectors.rs: [missing] -> pass (J2)
  • [ui] tests/ui/scalable-vectors/illformed-within-types.rs: [missing] -> pass (J2)
  • [ui] tests/ui/scalable-vectors/invalid.rs: [missing] -> pass (J2)
  • [ui] tests/ui/scalable-vectors/require-target-feature.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J2)

Stage 2

  • [codegen] tests/codegen-llvm/scalable-vectors/simple.rs: [missing] -> pass (J0)
  • [ui] tests/ui/scalable-vectors/async.rs: [missing] -> pass (J0)
  • [ui] tests/ui/scalable-vectors/closure-capture.rs: [missing] -> pass (J0)
  • [ui] tests/ui/scalable-vectors/copy-clone.rs: [missing] -> pass (J0)
  • [ui] tests/ui/scalable-vectors/require-target-feature.rs: [missing] -> pass (J0)
  • [ui] tests/ui/scalable-vectors/value-type.rs: [missing] -> pass (J0)
  • [ui] tests/ui/scalable-vectors/async.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J3)
  • [ui] tests/ui/scalable-vectors/require-target-feature.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J3)
  • [ui] tests/ui/scalable-vectors/value-type.rs: [missing] -> ignore (only executed when the architecture is aarch64) (J3)
  • [ui] tests/ui/scalable-vectors/illformed-tuples-of-scalable-vectors.rs: [missing] -> pass (J4)
  • [ui] tests/ui/scalable-vectors/invalid.rs: [missing] -> pass (J4)
  • [ui] tests/ui/scalable-vectors/wellformed-arrays.rs: [missing] -> pass (J4)
  • [ui] tests/ui/scalable-vectors/wellformed.rs: [missing] -> pass (J4)

(and 96 additional test diffs)

Additionally, 28 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 95a27adcf907bcc1046602c3746dad8cfdf3bf3f --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. pr-check-1: 1669.8s -> 1986.8s (+19.0%)
  2. x86_64-gnu-tools: 3157.7s -> 3672.2s (+16.3%)
  3. dist-x86_64-apple: 8129.0s -> 6997.4s (-13.9%)
  4. x86_64-gnu-gcc: 3072.1s -> 3490.6s (+13.6%)
  5. i686-gnu-nopt-1: 7341.0s -> 8337.5s (+13.6%)
  6. i686-gnu-2: 5423.4s -> 6119.8s (+12.8%)
  7. dist-ohos-armv7: 4649.0s -> 4071.1s (-12.4%)
  8. aarch64-gnu: 7492.3s -> 8422.8s (+12.4%)
  9. x86_64-gnu-miri: 4557.0s -> 5105.1s (+12.0%)
  10. x86_64-gnu-llvm-21-3: 6235.8s -> 6928.8s (+11.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@davidtwco davidtwco deleted the sve-infrastructure branch December 16, 2025 16:12
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (95a27ad): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.6%] 2
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 1.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.3% [1.6%, 4.4%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-3.0%, -0.6%] 2
All ❌✅ (primary) - - 0

Cycles

Results (secondary -1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.8% [3.8%, 3.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-4.9%, -2.4%] 3
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 54
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 45
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 54

Bootstrap: 478.546s -> 479.485s (0.20%)
Artifact size: 390.29 MiB -> 390.32 MiB (0.01%)

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. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.