Skip to content

refactor(comp): name clz and popcount after Metal's builtins - #1906

Merged
Lorenzobattistela merged 3 commits into
bendlang:mainfrom
MattCozendey:claude/bend-performance-features-gap-jxax2u
Oct 28, 2026
Merged

Lorenzobattistela merged 3 commits into
bendlang:mainfrom
MattCozendey:claude/bend-performance-features-gap-jxax2u

Conversation

@MattCozendey

Copy link
Copy Markdown
Contributor

-43 ttok, same behavior.

  • clz and popcount are Metal's own names, so Metal needs no alias lines; the CUDA and clang lanes define them, as SHIMS does for Metal's math names. Preprocessed C is byte-identical to main on the host, CUDA and Metal lanes.
  • str_in, in the JS runtime, has no caller.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JykXMQnSYXLQPmaG714Q1B

@Lorenzobattistela Lorenzobattistela self-assigned this Oct 28, 2026

@Lorenzobattistela Lorenzobattistela left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

bend2/effs/window.c:1249 (window_depth) still calls CLZ, which this PR removes on every lane, so any native build of a program that uses Window.frame now fails:

bend tests/gfx/window.bend -o out
error: call to undeclared function 'CLZ'; ISO C99 and later do not support implicit function declarations

Main builds the same file fine. window_depth is a copy of cls_fit (n > 1 ? 32 - clz(n - 1) : 0), so the simplest fix is to drop it and call cls_fit at its two uses (lines 1381 and 1932). That fixes the build and saves a few more tokens. The rest looks good, and str_in has no callers.

…e unused str_in (-43 ttok)

Metal needs no alias for either: the CUDA and clang lanes define clz
and popcount themselves, as SHIMS does for Metal's math names. The
preprocessed C is byte-identical on the host, CUDA and Metal lanes.
str_in, in the JS runtime, had no caller.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JykXMQnSYXLQPmaG714Q1B
@MattCozendey
MattCozendey force-pushed the claude/bend-performance-features-gap-jxax2u branch from 601c9d5 to 93843b6 Compare October 28, 2026 16:16
host() builds the call as `str_${out ? "out" : "in"}(...)`, so no caller
names str_in in full; without it a foreign JS effect that returns a String
throws a ReferenceError (tests/io/file_open_fifo_peer's peer_arm).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Lorenzobattistela Lorenzobattistela changed the title refactor(comp): name clz and popcount after Metal's builtins; drop the unused str_in (-43 ttok) refactor(comp): name clz and popcount after Metal's builtins Oct 28, 2026
@Lorenzobattistela
Lorenzobattistela merged commit 65a521f into bendlang:main Oct 28, 2026
1 check passed
@MattCozendey
MattCozendey deleted the claude/bend-performance-features-gap-jxax2u branch October 29, 2026 09:21
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.

3 participants