Re: What exactly is our CRC algorithm?

From: Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers(at)postgresql(dot)org, Andres Freund <andres(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: What exactly is our CRC algorithm?
Date: 2015-04-02 15:27:24
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

At 2015-04-02 17:58:23 +0300, hlinnaka(at)iki(dot)fi wrote:
> We're only using inline assembly to force producing SSE 4.2 code, even
> when -msse4.2 is not used. That feels wrong.

Why? It feels OK to me (and to Andres, per earlier discussions about
exactly this topic). Doing it this way allows the binary to run on a
non-SSE4.2 platform (and not use the CRC instructions).

Also, -msse4.2 was added to the compiler later than support for the
instructions was added to the assembler.

> We have a buildfarm animal that still uses gcc 2.95.3, which was
> released in 2001. I don't have a compiler of that vintage to test
> with, but I assume an old enough assembler would not know about the
> crc32q instruction and fail to compile.

GCC from <2002 wouldn't support the symbolic operand names in inline
assembly. binutils from <2007 (IIRC) wouldn't support the assembler
instructions themselves.

We could work around the latter by using the appropriate sequence of
bytes. We could work around the former by using the old syntax for

> I believe the GCC way to do this would be to put the SSE4.2-specific
> code into a separate source file, and compile that file with
> "-msse4.2". And when you compile with -msse4.2, gcc actually also
> supports the _mm_crc32_u8/u64 intrinsics.

I have no objection to this.

Building only that file with -msse4.2 would resolve the problem of the
output binary requiring SSE4.2; and the only compilers to be excluded
are old enough to be uninteresting at least to me personally.

Have you done/are you doing this already, or do you want me to? I could
use advice on how to add build flags to only one file, since I don't
know of any precendent for that.

-- Abhijit

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-04-02 15:45:56 pgsql: Define integer limits independently from the system definitions.
Previous Message Heikki Linnakangas 2015-04-02 14:58:23 Re: What exactly is our CRC algorithm?