Re: vectorized CRC on ARM64
John Naylor <johncnaylorls@gmail.com>
From: John Naylor <johncnaylorls@gmail.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-01T11:48:10Z
Lists: pgsql-hackers
On Wed, Apr 1, 2026 at 1:21 AM Nathan Bossart <nathandbossart@gmail.com> wrote: > > On Tue, Mar 31, 2026 at 06:19:49PM +0700, John Naylor wrote: > > In master, we can have one of: > > > > CFLAGS_CRC="" > > CFLAGS_CRC="-march=armv8-a+crc+simd" > > CFLAGS_CRC="-march=armv8-a+crc" > > > > ...and then based on that we set either USE_ARMV8_CRC32C or > > USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK, and set PG_CRC32C_OBJS. > > > > But below that, v3 runs a new test for pmull instructions with the > > flag "-march=armv8-a+crc+simd+crypto" and if it links, it will reset > > CFLAGS_CRC to that set of flags. That doesn't seem like the right > > thing to do, but I don't see a good alternative. I suppose I could > > sidestep that with function attributes, but that's not as well > > supported. Another idea would be to turn the relevant line here > > > > if test x"$Ac_cachevar" = x"yes"; then > > CFLAGS_CRC="$1" > > pgac_arm_pmull_intrinsics=yes > > fi > > > > ...into CFLAGS_CRC="CFLAGS_CRC$1", where in this case $1 is just > > "+crypto". That seems even more fragile, though. > > Appending +crypto to the current CFLAGS_CRC seems like the right thing to > do to me. I'm trying to understand why you are concerned about fragility. > I suppose someone could add something else between the existing checks and > the one you're adding that appends a different option or something, but > besides that, I'd think merely appending +crypto to the -march value > wouldn't invalidate previous tests or anything like that. Maybe it's a low risk, but this stuff is awfully difficult to debug when it goes wrong. 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. -- John Naylor Amazon Web Services
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use C11 alignas instead of pg_attribute_aligned
- 182f6944d3d0 19 (unreleased) landed
- 8061bfd15abe master landed
-
Add missing guard for __builtin_constant_p
- 936d8974c3bc 18.4 landed
- 676626426285 19 (unreleased) landed
-
Exit early from pg_comp_crc32c_pmull for small inputs
- 948ef7cdc499 19 (unreleased) landed
-
Fix unused function warning on Arm platforms
- 2849fe4c9785 19 (unreleased) landed
-
Compute CRC32C on ARM using the Crypto Extension where available
- fbc57f2bc2ee 19 (unreleased) landed