On Thu, Oct 22, 2026 at 2:38 PM Shreesh Adiga <[email protected]> wrote: > > > > On Thu, Oct 22, 2026 at 12:26 PM Uros Bizjak <[email protected]> wrote: >> >> On Wed, Oct 21, 2026 at 12:21 PM Shreesh Adiga >> <[email protected]> wrote: >> > >> > This patch extends pclmul expanders for the i386 backend to >> > generate optimized code for CRC64 computations. >> > >> > This is an extension to the 16-bit and 32-bit data CRC computation added >> > earlier. The algorithm is slightly different which is described in the >> > paper "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ >> > Instruction" described in the section >> > "Barrett Reduction Algorithm for a degree-64 polynomial modulus >> > (polynomials defined over GF(2))" Page 17 and 18. >> > >> > Bit-reverse CRC also is based on the above, except that the bit 65 after >> > performing bit-reflect of polynomial maybe 0 and thus the xor operation >> > needs to be conditionally performed only when LSB=1. >> > >> > The quotient computation which needs 65 bits now returns the lower 64 >> > bits and the 65th bit is assumed to be 1 since the polynomials are >> > expected to have the leading bit to be 1. Thus the assert is modified to >> > allow the 64 bit cases as well. >> > >> > Added tests for covering 8-bit, 16-bit, 32-bit and 64-bit for both >> > forward and reverse CRC64, along with reverse CRC64 testing for >> > polynomials with LSB=0 and LSB=1 as well that gets passed into the CRC >> > expander. >> > >> > gcc/ChangeLog: >> > >> > * config/i386/i386-expand.cc (ix86_expand_crc_using_pclmul): >> > Modified to allow 64-bit CRC. >> > (ix86_expand_reversed_crc_using_pclmul): Likewise. >> > * config/i386/i386.md (crc<SWI248x:mode><SWI24:mode>4): Renamed >> > the second iterator to allow 64-bit CRC. >> > (crc<SWI1248x:mode><SWI248x:mode>4): Likewise. >> > (crc_rev<SWI1248x:mode><SWI24:mode>4): Likewise. >> > (crc_rev<SWI1248x:mode><SWI248x:mode>4): Likewise. >> > * expr.cc (gf2n_poly_long_div_quotient): Relaxed assert to allow >> > computing lower 64-bit of quotient for 64-bit CRC. >> > >> > gcc/testsuite/ChangeLog: >> > >> > * gcc.dg/torture/crc-34.c: New test. >> > * gcc.dg/torture/crc-35.c: New test. >> > * gcc.dg/torture/crc-36.c: New test. >> > * gcc.dg/torture/crc-37.c: New test. >> > * gcc.dg/torture/crc-38.c: New test. >> > * gcc.dg/torture/crc-39.c: New test. >> > * gcc.dg/torture/crc-40.c: New test. >> > * gcc.dg/torture/crc-41.c: New test. >> > * gcc.target/i386/crc-34-pclmul.c: New test. >> > * gcc.target/i386/crc-35-pclmul.c: New test. >> > * gcc.target/i386/crc-36-pclmul.c: New test. >> > * gcc.target/i386/crc-37-pclmul.c: New test. >> > * gcc.target/i386/crc-38-pclmul.c: New test. >> > * gcc.target/i386/crc-39-pclmul.c: New test. >> > * gcc.target/i386/crc-40-pclmul.c: New test. >> > * gcc.target/i386/crc-41-pclmul.c: New test. >> >> OK. >> >> Reviewed-by: Uros Bizjak <[email protected]> >> >> expr.cc change was approved by Jeff in [1]. >> >> Pushed. >> >> [1] https://gcc.gnu.org/pipermail/gcc-patches/2026-October/735613.html >> > > I believe that there is some confusion here. > The approval in [1] was for crc32 const fold assert removal in > calculate_reversed_crc. > Whereas this assert change is in a different function > gf2n_poly_long_div_quotient. > > Since this is already merged I'm assuming it won't be immediately reverted > unless > there is some bug. Kindly let me know if the changes done are incorrect.
Ouch... my bad. I was 100% the approval is for expr.cc. Let's wait a bit for eventual approval. Otherwise, we will revert the expr.cc change and disable unsupported i386.md patterns with <SWI248x:MODE>mode != DImode expander condition. However, following your comment, the change is sound: + /* The result has degree N, so needs N + 1 bits. + For 64-bit CRC, compute the lower 64 bits of the division. + The 65th bit is 1 since the leading bit of polynomial is 1. */ + gcc_assert (n <= 64); and the functionality works w/o problems for x86. Uros.
