gcc now has builtin functions for CRCs https://gcc.gnu.org/onlinedocs/gcc/CRC-Builtins.html
Conversation
Notices
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 16:08:38 JST
✧✦Catherine✦✧
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 17:48:01 JST
✧✦Catherine✦✧
@f4grx beats me
In conversation permalink -
Embed this notice
F4GRX Sébastien (f4grx@chaos.social)'s status on Saturday, 30-Aug-2025 17:48:03 JST
F4GRX Sébastien
@whitequark whats the goal of these? Performance?
In conversation permalink -
Embed this notice
8051 enthusiast (8051enthusiast@mastodon.social)'s status on Saturday, 30-Aug-2025 19:29:10 JST
8051 enthusiast
@whitequark i can't believe we're getting crc builtins and a llvm loopidiom pr that recognizes crcs but there is still no clmul builtin
In conversation permalink -
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 19:32:28 JST
✧✦Catherine✦✧
@8051enthusiast eli5: why is clmul so useful?
In conversation permalink -
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 19:36:04 JST
✧✦Catherine✦✧
@8051enthusiast also, loopidiom, seriously? who added that?
In conversation permalink -
Embed this notice
8051 enthusiast (8051enthusiast@mastodon.social)'s status on Saturday, 30-Aug-2025 19:36:50 JST
8051 enthusiast
@whitequark it's not merged yet, just a pr: https://github.com/llvm/llvm-project/pull/143208
In conversation permalink Attachments
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 19:40:07 JST
✧✦Catherine✦✧
@8051enthusiast oh, the code is less bad than I thought
In conversation permalink -
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 19:47:24 JST
✧✦Catherine✦✧
In conversation permalink -
Embed this notice
Simon Brenner (olsner@social.vivaldi.net)'s status on Saturday, 30-Aug-2025 19:47:25 JST
Simon Brenner
@f4grx @whitequark I would say the point is convenient arch-independent access to crc hardware - you should get the special instruction when the polynomial matches whatever your cpu has and hopefully a clmul based fallback before resorting to a table. Much nicer than a tangle of ifdefs for every architecture and the research needed to know every crc instruction and which crc variant it produces…
I guess if you were properly enthusiastic about crcs you’d already be maintaining specialized assembly for 14 architectures and every commonly used polynomial and this is not so interesting… but now the rest of us can get gcc (or gcc’s architecture maintainers) to do it for us?
In conversation permalink -
Embed this notice
8051 enthusiast (8051enthusiast@mastodon.social)'s status on Saturday, 30-Aug-2025 19:48:01 JST
8051 enthusiast
@whitequark for CRCs specifically, since CRC is basically a polynomial remainder, you can optimize it to clmul the same way you can optimize "integer modulo a constant" to integer multiplications. it's also useful in cryptographic contexts whenever there are fields over GF(2). i also would have found it useful a bunch of times i wanted to rearrange some bits (which can be done in a way similar to normal integer multiplication to spread bits, but without having to worry about carry bits)
In conversation permalink -
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 19:48:31 JST
✧✦Catherine✦✧
@8051enthusiast aha so this is on point: https://mastodon.social/@whitequark/115117315959503306
In conversation permalink Attachments
-
Embed this notice
✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Saturday, 30-Aug-2025 19:48:31 JST
✧✦Catherine✦✧
@8051enthusiast I do not at all understand CRCs or how one can be a "polynomial remainder"
In conversation permalink -
Embed this notice
8051 enthusiast (8051enthusiast@mastodon.social)'s status on Saturday, 30-Aug-2025 19:59:55 JST
8051 enthusiast
@whitequark @olsner @f4grx hmm i think that's wrong. but if you had a 32-bit integer, you could do clmul(x, 1 ^ (1 << 32)) >> r (with some extra integer casting) which is the same as (x | (x << 32)) >> r
In conversation permalink -
Embed this notice
8051 enthusiast (8051enthusiast@mastodon.social)'s status on Saturday, 30-Aug-2025 21:38:37 JST
8051 enthusiast
@whitequark ok so i wanted to attempt to explain this, but it got too long and still skipped too many steps, sorry! anyways, here's the draft in case you still want to read it: https://gist.github.com/8051Enthusiast/9d737c081a356bf47b4ea1f434ffe417
In conversation permalink Attachments
-
Embed this notice