Skip to content

Conversation

korran
Copy link
Contributor

@korran korran commented Oct 17, 2025

The crc32 instructions are non-standard and not supported by upstream clang.

According to perftest, this only slows things down by a few cycles

before:
I00003 crc32_perftest.c:33] CRC32 computed in 11343 cycles. 
I00004 crc32_perftest.c:33] CRC32 computed in 11317 cycles. 
I00005 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00006 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00007 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00008 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00009 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00010 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00011 crc32_perftest.c:33] CRC32 computed in 11314 cycles. 
I00012 crc32_perftest.c:33] CRC32 computed in 11314 cycles.

after:
I00003 crc32_perftest.c:33] CRC32 computed in 11358 cycles. 
I00004 crc32_perftest.c:33] CRC32 computed in 11319 cycles. 
I00005 crc32_perftest.c:33] CRC32 computed in 11318 cycles. 
I00006 crc32_perftest.c:33] CRC32 computed in 11318 cycles. 
I00007 crc32_perftest.c:33] CRC32 computed in 11318 cycles. 
I00008 crc32_perftest.c:33] CRC32 computed in 11318 cycles. 
I00009 crc32_perftest.c:33] CRC32 computed in 11318 cycles. 
I00010 crc32_perftest.c:33] CRC32 computed in 11318 cycles. 
I00011 crc32_perftest.c:33] CRC32 computed in 11318 cycles.

@korran korran requested a review from a team as a code owner October 17, 2025 22:36
@korran korran requested review from pamaury and removed request for a team October 17, 2025 22:36
@cfrantz cfrantz requested a review from luismarques October 17, 2025 22:38
@cfrantz
Copy link
Contributor

cfrantz commented Oct 17, 2025

bazel run //quality:clang_format_fix to fix the C++ formatting.

The crc32 instructions are non-standard and not supported by upstream
clang.

According to perftest, this only slows things down by a few cycles

before:
I00003 crc32_perftest.c:33] CRC32 computed in 11343 cycles.
I00004 crc32_perftest.c:33] CRC32 computed in 11317 cycles.
I00005 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00006 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00007 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00008 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00009 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00010 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00011 crc32_perftest.c:33] CRC32 computed in 11314 cycles.
I00012 crc32_perftest.c:33] CRC32 computed in 11314 cycles.

after:
I00003 crc32_perftest.c:33] CRC32 computed in 11358 cycles.
I00004 crc32_perftest.c:33] CRC32 computed in 11319 cycles.
I00005 crc32_perftest.c:33] CRC32 computed in 11318 cycles.
I00006 crc32_perftest.c:33] CRC32 computed in 11318 cycles.
I00007 crc32_perftest.c:33] CRC32 computed in 11318 cycles.
I00008 crc32_perftest.c:33] CRC32 computed in 11318 cycles.
I00009 crc32_perftest.c:33] CRC32 computed in 11318 cycles.
I00010 crc32_perftest.c:33] CRC32 computed in 11318 cycles.
I00011 crc32_perftest.c:33] CRC32 computed in 11318 cycles.

Signed-off-by: Kor Nielsen <[email protected]>
Copy link
Contributor

@luismarques luismarques left a comment

Choose a reason for hiding this comment

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

Overall LGTM. See the inline comment about zbc.

asm(".option push;"
".option arch, +zbr0p93;"
"crc32.b %0, %1;"
".option arch, +zbc;"
Copy link
Contributor

Choose a reason for hiding this comment

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

The -march arch string we use already includes zbc, so the .option arch, +zbc shouldn't be needed here.

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