Skip to content

Clean up crc32_braid/chorba calls.#2133

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
nmoinvaz:improvements/crc32-chorba
Feb 1, 2026
Merged

Clean up crc32_braid/chorba calls.#2133
Dead2 merged 1 commit intozlib-ng:developfrom
nmoinvaz:improvements/crc32-chorba

Conversation

@nmoinvaz
Copy link
Copy Markdown
Member

No description provided.

@nmoinvaz nmoinvaz added the cleanup Improving maintainability or removing code. label Jan 29, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

Promotes and inlines the braid implementation by renaming crc32_braid_internalcrc32_braid (parameter ccrc), moves CRC inversion to function entry, and updates nondestructive chorba paths and SSE2/SSE4.1 variants to initialize/return with inverted CRC and to route short inputs through crc32_braid.

Changes

Cohort / File(s) Summary
Core CRC Braid Refactor
arch/generic/crc32_braid_c.c, arch/generic/generic_functions.h
Renamed and inlined crc32_braid_internalcrc32_braid (param ccrc), applied crc = ~crc at entry, removed internal wrapper and header prototype.
Generic Chorba
arch/generic/crc32_chorba_c.c
Nondestructive variants now initialize using ~crc and return ~crc (or call crc32_braid(~crc, ...)); short-input routing updated to call crc32_braid when appropriate; function signatures/formats standardized.
x86 SSE2 Variant
arch/x86/chorba_sse2.c
Renamed parameter bufinput in nondestructive helper; initialize/return use ~crc; added early short-path returning via crc32_braid; alignment and routing adjusted to propagate inverted CRC.
x86 SSE4.1 Variant
arch/x86/chorba_sse41.c
Parameter rename bufinput in nondestructive function; initialize/return with ~crc; added short-circuit to use crc32_braid for small inputs; simplified routing to nondestructive paths and removed redundant post-processing.

Possibly related PRs

Suggested reviewers

  • Dead2
  • KungFuJesus
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description explaining the purpose and scope of the CRC32 function refactoring, parameter renaming, and call pattern changes across all modified files.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Clean up crc32_braid/chorba calls' accurately summarizes the main changes: refactoring internal CRC32 functions (crc32_braid and chorba variants) to consolidate public/internal interfaces and update call patterns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
arch/generic/crc32_braid_c.c (1)

209-211: Remove duplicate crc32_braid definition (build breaks).

There are two crc32_braid definitions, and the second one calls crc32_braid_internal, which no longer exists. This matches the CI redefinition/implicit-declaration failures.

🧹 Suggested fix (remove the stale wrapper)
-Z_INTERNAL uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, size_t len) {
-    return ~crc32_braid_internal(~crc, buf, len);
-}
arch/x86/chorba_sse2.c (1)

23-846: SSE2 small chorba now returns pre-conditioned CRC.

After the inversion refactor, this path still seeds with raw crc and returns crc without a final complement, which likely makes SSE2 results inconsistent with generic paths and the updated wrapper behavior.

✅ Suggested fix to re-align with post-conditioned outputs
-    uint64_t next1 = crc;
+    uint64_t next1 = ~crc;
@@
-    return crc;
+    return ~crc;
arch/x86/chorba_sse41.c (1)

55-303: SSE4.1 32K chorba path still missing CRC complement.

With the wrapper now returning directly, this function still treats crc as pre-conditioned and returns it without the final ~, which likely breaks parity with the generic path.

✅ Suggested fix to re-align with post-conditioned outputs
-    __m128i init_crc = _mm_cvtsi64_si128(crc);
+    __m128i init_crc = _mm_cvtsi64_si128(~crc);
@@
-    return crc;
+    return ~crc;

@nmoinvaz nmoinvaz force-pushed the improvements/crc32-chorba branch from b81f07f to fa0e43b Compare January 29, 2026 18:43
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

@nmoinvaz nmoinvaz force-pushed the improvements/crc32-chorba branch from fa0e43b to 8176a7e Compare January 29, 2026 19:35
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 29, 2026

Coverage Status

coverage: 94.617%. first build
when pulling d2df036 on nmoinvaz:improvements/crc32-chorba
into 4016545 on zlib-ng:develop.

@nmoinvaz nmoinvaz force-pushed the improvements/crc32-chorba branch 2 times, most recently from 802b354 to 6b04b9d Compare January 30, 2026 03:51
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

@nmoinvaz nmoinvaz force-pushed the improvements/crc32-chorba branch 2 times, most recently from 35285df to 3c01ff8 Compare January 30, 2026 04:46
@nmoinvaz nmoinvaz marked this pull request as ready for review January 30, 2026 04:54
@nmoinvaz nmoinvaz force-pushed the improvements/crc32-chorba branch from 3c01ff8 to d2df036 Compare January 30, 2026 05:06
Copy link
Copy Markdown
Member

@Dead2 Dead2 left a comment

Choose a reason for hiding this comment

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

LGTM

@Dead2 Dead2 merged commit e73ab48 into zlib-ng:develop Feb 1, 2026
148 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Improving maintainability or removing code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants