Using a 64-bit CRC algorithm implementation implemented using "long long int", it has been found that gcc fails to optimise the algorithm correctly when the -O2 parameter is used. In fact, it is found that the processing time for CRC calculation more than doubles compared to the processing time for the algorithm when the -O1 parameter is used.
Tom Lane from Red Hat has done some testing and discovered that this problem only occurs on 32-bit Intel processors (see http://archives.postgresql.org/pgsql-hackers/2005-05/msg01051.php for more information and the results of tests on other architectures). I've marked this issue under version "unknown", however the URL above shows that the problem exists in versions 3.2.3, 3.3.2 and 4.0.0. The test case is easy: compile and run the attached crctest64.c on an Intel 32-bit processor such as a P4/Xeon with the following options: gcc -O1 crctest64.c -o crctest64-o1 gcc -O2 crctest64.c -o crctest64-o2 Comparison of the timings will show that the second version is at least 100% slower than the first. Many thanks, Mark. -- Summary: CRC64 algorithm optimisation problem on Intel 32-bit Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P2 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: m dot cave-ayland at webbased dot co dot uk CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21617