Skip to content

Only compile Fallback level on targets without a better baseline - #320

Merged
Shnatsel merged 5 commits into
linebender:mainfrom
Shnatsel:do-not-compile-fallback
Aug 7, 2026
Merged

Only compile Fallback level on targets without a better baseline#320
Shnatsel merged 5 commits into
linebender:mainfrom
Shnatsel:do-not-compile-fallback

Conversation

@Shnatsel

@Shnatsel Shnatsel commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

It emitted no LLVM IR, but it was still being type- and borrow-checked despite never being called.

When applied on top of #318 reduces x86 clean build time by 0.2s (from 2.15s to 1.95s) and Aarch64 build time by 0.3s (from 1.25s to 0.95s).

Fixes #316

There are two instances of this cfg, which is as low as I could get it. Could be brought down to one with a build script but that would negate the build time gains.

@Shnatsel Shnatsel mentioned this pull request Aug 7, 2026

@DJMcNab DJMcNab 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!

This does leave me with a niggling doubt about whether we should return to doing this more generally (e.g. separating the "proof types" used for kernel from the Simd impls to improve build time). But I suspect the cases where that would actually come up are so niche it's not worth worrying about in practise.

Comment thread CHANGELOG.md

- The `new_unchecked()` function on SIMD level tokens such as `Avx2` has been renamed to `assume_supported()` and is now safe to call from contexts that already contain the appropriate `#[target_feature]` annotations. Functions without such annotations can still call `assume_supported()` with an `unsafe` block. ([#293][] by [@Shnatsel][])
- On x86_64 targets with static SSE2 support, `Level::baseline()` now returns `Sse2` instead of `Fallback`. ([#270][] by [@Shnatsel][])
- The scalar `Fallback` backend and `Level::Fallback` variant are no longer compiled when the target has a better ambient SIMD baseline (e.g. SSE2 on x86, NEON on Aarch64). The `force_support_fallback` feature continues to make them available for testing. `disable_dispatch_sse2` no longer disables SSE2 if it is the baseline level.

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.

This should have the pr number reference (by the way, I've been working on tooling to make our changelog management better - see https://github.com/DJMcNab/release_eng/blob/main/gazeto/README.md - which I'd appreciate if you had any feedback on).

@Shnatsel Shnatsel Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I feel my current workflow of having an LLM go through the git history and write a draft, then editing the PR summaries manually works well. See #314 for what the result looks like.

And frankly I don't want to be beholden to even more inflexible tools than this repository already is.

Comment thread fearless_simd/src/lib.rs
@Shnatsel

Shnatsel commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

This does leave me with a niggling doubt about whether we should return to doing this more generally (e.g. separating the "proof types" used for kernel from the Simd impls to improve build time). But I suspect the cases where that would actually come up are so niche it's not worth worrying about in practise.

I thought about this and came to the same conclusion.

There is however a related use case: when a kernel! macro accepts e.g. AVX2, this could in theory be satisfied with any level that is AVX2 or higher. So if the host actually has AVX-512 it can give kernel! calls e.g. better AVX-512 loads if there's -C target-cpu=icelake-server active. But I don't think this is very useful in practice, and LLVM should optimize trivial things like loads anyway, while more complex ops inside kernel! are not that common.

@Shnatsel
Shnatsel enabled auto-merge August 7, 2026 23:10
@Shnatsel
Shnatsel added this pull request to the merge queue Aug 7, 2026
Merged via the queue into linebender:main with commit 6febd86 Aug 7, 2026
22 checks passed
@Shnatsel
Shnatsel deleted the do-not-compile-fallback branch August 7, 2026 23:17
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.

Fallback level is compiled on platforms where it's not needed

2 participants