Re: vectorized CRC on ARM64

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: John Naylor <johncnaylorls@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-01T15:24:40Z
Lists: pgsql-hackers
On Wed, Apr 01, 2026 at 06:48:10PM +0700, John Naylor wrote:
> I don't think appending +crypto would work everywhere IIUC -- if the
> packager set +crc in the CFLAGS, then CFLAGS_CRC="" so there is no
> existing -march to put it on, and the PMULL check would fail. Maybe
> that's okay if we call that out in the release notes, since that's
> probably rare. Then we could check both with and without +crypto
> tacked on.
> 
> I tried appending the new -march value, and that works since last one
> wins. But that might have the same problem as above if the packager
> put something special in CFLAGS for -march, that would get wiped out
> by our new one.

The other idea I had was to always add +crypto in the existing tests
(unless we're not setting CFLAGS_CRC), and then to just do the PMULL check
with whatever CFLAGS_CRC is set to, not bothering to try different values.
That doesn't fix the problem you mentioned in the quoted text, but maybe
it's a little sturdier.

... or maybe we should just use __attribute__((target("..."))) for the
PMULL stuff.  That wouldn't work well for clang versions before 16, but it
at least wouldn't regress anything.  They just wouldn't get PMULL support.

-- 
nathan



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Use C11 alignas instead of pg_attribute_aligned

  2. Add missing guard for __builtin_constant_p

  3. Exit early from pg_comp_crc32c_pmull for small inputs

  4. Fix unused function warning on Arm platforms

  5. Compute CRC32C on ARM using the Crypto Extension where available