Skip to content

Reinterpret arrays in fallback split and combine instead of copy_from_slice - #446

Merged
Shnatsel merged 1 commit into
linebender:mainfrom
LaurenzV:fallback-split-combine
Nov 24, 2026
Merged

Shnatsel merged 1 commit into
linebender:mainfrom
LaurenzV:fallback-split-combine

Conversation

@LaurenzV

@LaurenzV LaurenzV commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

I'm currently trying to integrate filtra into resvg, which builds on top of fearless_simd. The problem we have observed is that when building with opt-level z (which optimizes for size), we are seeing some slowdowns and more importantly, a very large increase in binary size on the scalar WASM build.

The problem seems to arise from the 256-bit and 512-bit ops, which use the split and combine approach. Apparently, using copy_from_slice here fails to properly optimize the memory copies away for this optimization level, hence the large binary size bloat and also worse performance. Using our existing checked_transmute_copy helper seems to fix it. Unfortunately scalar WASM builds are still important for resvg, so this is probably a blocker.

Here you can see the differences in binary size and also performance. main is current resvg main, stock is the filtra integration with fearless_simd 1.2, and new is with this branch:

image

@LaurenzV
LaurenzV requested review from Shnatsel and removed request for Shnatsel November 24, 2026 18:15
@LaurenzV
LaurenzV marked this pull request as draft November 24, 2026 18:33
…_slice

At opt-level = "z", LLVM keeps the copy_from_slice calls in the fallback's
split and combine as copies through aligned stack slots. Every operation on a
vector wider than 128 bits goes through them, so those operations end up
several times larger and slower than at opt-level = 3. Reinterpreting the
arrays with checked_transmute_copy lets LLVM keep the values in locals at both
levels.
@LaurenzV
LaurenzV force-pushed the fallback-split-combine branch from b1adebd to a2b7038 Compare November 24, 2026 18:36
@LaurenzV LaurenzV changed the title Build fallback split and combine from lanes instead of copy_from_slice Reinterpret arrays in fallback split and combine instead of copy_from_slice Nov 24, 2026
@LaurenzV
LaurenzV requested a review from Shnatsel November 24, 2026 18:39
@LaurenzV
LaurenzV marked this pull request as ready for review November 24, 2026 18:39
@Shnatsel
Shnatsel added this pull request to the merge queue Nov 24, 2026
Merged via the queue into linebender:main with commit 17af9ca Nov 24, 2026
23 checks passed
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.

2 participants