You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the five missing stdc_count_ones_{uc,us,ui,ul,ull} libc exports using the existing C++20 std::popcount support in IntegerBuiltins.cpp. Each returns the number of set bits as uint32_t. Inputs are unsigned 8, 16, 32, 64 and 64 bits respectively; ul explicitly stays 64-bit on Windows to preserve the guest LP64 ABI. Each export has one public declaration, and each width has its own regression test.
The first three original functions count the bits of the zero-extended argument in edi; the last two count the 64-bit argument in rdi. All five are call-free leaves returning that count. They were also executed directly on a Windows host as described below. No console measurement is claimed; this gap is recorded beside the integer builtins in docs/dev/debt/libc.md. No original binary, byte dump, third-party source, investigation notes or logs are committed.
Tested
Runtime-tested head: a32936391b6d43cf702324b2870106682b2607b7, based on main e2d457be345d62842ec929ca08680bb1286c6830. Published head: 218e9c7e4e5be8f45246ea159707e3f22344adab, based on main 27ad7244d22153ebfd576e04e3c4d63e0b92264b (27 October 2026).
After those runtime tests, main received graphics-only updates in AGC, AGCDriver and the shader recompiler. The branch was rebased onto the newer base and its debt entry moved to avoid documentation conflicts. All libc production sources, declarations, CMake registration and regression sources are byte-identical to the runtime-tested head; no libc path changed between the two main bases. The runtime and native differential results below belong to the stated tested head. Conventions, whitespace, strict synchronization and the final overlap comparison were checked again on the published head.
Windows 11 / WinLibs MinGW-w64 GCC 15.2.0 and Ubuntu 24.04 WSL / GCC 13.3.0, Release, existing full-project configurations with bundled pinned dependencies: rebuilt production libc, guest_count_ones_tests and guest_integer_builtins_tests. ctest --test-dir build -R "^(guest_count_ones_(uc|us|ui|ul|ull)|guest_integer_builtins|public_headers)$" -V --output-on-failure passes 7/7 on each platform (20.29 s Windows, 14.87 s Ubuntu). public_headers checks unique declarations and umbrella coverage.
The five new cases use an independent shift-and-add reference: all 8- and 16-bit values, zero/all-ones, every single-bit and two-bit position, complements, and 100,000 deterministic random inputs plus their complements per wider type. They check that guest errno is preserved. Tests are separated by width and retain a 20-second timeout each.
Direct original-versus-production comparison on Windows: 169,763 input vectors, 848,815 original calls and 848,815 candidate calls, zero mismatches, also checked against an independent reference. The candidate is the built production libc reached through all five patched NIDs, and those names were independently hashed with tools/nid_names.py. Only the five original call-free leaves were executed from mapped load segments; no original initialization, relocation, other export or title execution was performed. This is host evidence, not a console result.
Before implementation, guest_integer_builtins and public_headers passed 2/2 on each platform on main cb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f. That base and the final base above have identical libc production/header/test/CMake sources; intervening main changes affect tools and AudioOut.
Negative control on the initial implementation validation: replacing all five production bodies with NotImplemented_nid_no_patch(__func__) makes all five new tests fail. Restoring production makes all five pass with the identical test executable (SHA256 8fec8c9465cc76ce3ba5717b1520d01d07338d57f6719dbd72f13f705b0e1b05). This control belongs to initial head b03e248a0187db267c24c87f75236fd34e521daf; the final refresh changed only the debt-note position and removed a trailing blank line from the test file, preserving all production bodies and assertions. The runtime-tested head's full focused tests and native differential were rerun separately above, before the final documentation-only adjustment and rebase.
Conventions, PR whitespace and strict main-sync checks pass on the published head: one commit ahead, zero behind main 27ad7244d22153ebfd576e04e3c4d63e0b92264b. No new dependency or comments in code.
The full CTest suite, all standalone-header compilation batches, macOS, console, title and GPU execution were not tested. No title unblock or performance improvement is claimed.
Checklist
Based on current main; no other open PR implements the same functions
The reason will be displayed to describe this comment to others. Learn more.
Reviewed exact head 218e9c7e4e5be8f45246ea159707e3f22344adab. The five declarations, std::popcount implementations and per-width CTest registration are consistent, including the explicit 64-bit ul guest ABI on Windows. The regression tests use an independent shift reference, exhaustive 8/16-bit inputs, edge patterns and deterministic wider inputs; the debt note accurately says console behavior is not measured. I verified the changed test and implementation translation units with c++ -std=c++20 -fsyntax-only (using the PR header for its new declarations), and git diff --check plus conventions pass. Hosted eligibility, conventions, intake, labels, report, Ubuntu/Windows relinker, ASan and Ubuntu register-context checks pass. macOS jobs are still queued; Linux/Windows product jobs were skipped by path policy. The PR reports separate Windows and Ubuntu runtime/differential testing on its stated tested head; I did not rerun those full tests locally.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
Checked the five NIDs against tools/nid_names.py, the std::popcount bodies (8/16/32/64/64-bit inputs, uint32_t result, ul 64-bit on Windows), the per-width ctest registration and the independent-reference tests (exhaustive 8/16-bit, edge and random wider inputs), and the debt entry; merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implement the five missing
stdc_count_ones_{uc,us,ui,ul,ull}libc exports using the existing C++20std::popcountsupport inIntegerBuiltins.cpp. Each returns the number of set bits asuint32_t. Inputs are unsigned 8, 16, 32, 64 and 64 bits respectively;ulexplicitly stays 64-bit on Windows to preserve the guest LP64 ABI. Each export has one public declaration, and each width has its own regression test.Contract evidence is the
libc.prxbundled with PPSA03671 v01.001.005 (SHA256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6), supplemented by C23 draft N3220, section 7.18.12 and the LLVM libc stdbit signatures.stdc_count_ones_ucVV9JOsHi9f00x307b0stdc_count_ones_usgnkfi6EgH+A0x307c0stdc_count_ones_uilCm3HL3DTMk0x307d0stdc_count_ones_ulnz-w4D57ff00x307e0stdc_count_ones_ull2HLlqICSbCA0x307f0The first three original functions count the bits of the zero-extended argument in
edi; the last two count the 64-bit argument inrdi. All five are call-free leaves returning that count. They were also executed directly on a Windows host as described below. No console measurement is claimed; this gap is recorded beside the integer builtins indocs/dev/debt/libc.md. No original binary, byte dump, third-party source, investigation notes or logs are committed.Tested
Runtime-tested head:
a32936391b6d43cf702324b2870106682b2607b7, based on maine2d457be345d62842ec929ca08680bb1286c6830. Published head:218e9c7e4e5be8f45246ea159707e3f22344adab, based on main27ad7244d22153ebfd576e04e3c4d63e0b92264b(27 October 2026).After those runtime tests, main received graphics-only updates in AGC, AGCDriver and the shader recompiler. The branch was rebased onto the newer base and its debt entry moved to avoid documentation conflicts. All libc production sources, declarations, CMake registration and regression sources are byte-identical to the runtime-tested head; no libc path changed between the two main bases. The runtime and native differential results below belong to the stated tested head. Conventions, whitespace, strict synchronization and the final overlap comparison were checked again on the published head.
guest_count_ones_testsandguest_integer_builtins_tests.ctest --test-dir build -R "^(guest_count_ones_(uc|us|ui|ul|ull)|guest_integer_builtins|public_headers)$" -V --output-on-failurepasses 7/7 on each platform (20.29 s Windows, 14.87 s Ubuntu).public_headerschecks unique declarations and umbrella coverage.tools/nid_names.py. Only the five original call-free leaves were executed from mapped load segments; no original initialization, relocation, other export or title execution was performed. This is host evidence, not a console result.guest_integer_builtinsandpublic_headerspassed 2/2 on each platform on maincb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f. That base and the final base above have identical libc production/header/test/CMake sources; intervening main changes affect tools and AudioOut.NotImplemented_nid_no_patch(__func__)makes all five new tests fail. Restoring production makes all five pass with the identical test executable (SHA2568fec8c9465cc76ce3ba5717b1520d01d07338d57f6719dbd72f13f705b0e1b05). This control belongs to initial headb03e248a0187db267c24c87f75236fd34e521daf; the final refresh changed only the debt-note position and removed a trailing blank line from the test file, preserving all production bodies and assertions. The runtime-tested head's full focused tests and native differential were rerun separately above, before the final documentation-only adjustment and rebase.27ad7244d22153ebfd576e04e3c4d63e0b92264b. No new dependency or comments in code.IntegerBuiltins.cpp. This targeted review is not a claim that those stale branches merge cleanly or were runtime-tested together.The full CTest suite, all standalone-header compilation batches, macOS, console, title and GPU execution were not tested. No title unblock or performance improvement is claimed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)