https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122041
--- Comment #10 from Petr Sumbera <sumbera at volny dot cz> ---
Adding -flto and -O3 also for test.c does seem make the difference.
I also had to modify test.c to use calculated crc value like this. Otherwise
call to crc32_update_no_xor() was probably completely optimized out (and the
test ended immediately).
--- test.c
+++ test.c
@@ -29,6 +29,7 @@
}
free(buf);
+ printf("Last crc was %x\n", crc);
return 0;
}
==
PATH=/usr/gcc/15/bin/:/usr/bin/ gmake test
gcc -flto -O3 -o test.o -c test.c
gcc -flto -O3 -funroll-loops -mcpu=niagara4 -mtune=niagara4 -o crc-gcc.o -c
crc.c
gcc -flto -o test-gcc test.o crc-gcc.o
/opt/developerstudio12.6/bin/cc -m64 -xO4 -xtarget=generic -xarch=sparcvis
-xchip=generic -xregs=no%appl -xmemalign=16s -o crc-studio.o -c crc.c
gcc -o test-studio test.o crc-studio.o
time ./test-gcc
Last crc was 6d0c33d0
real 10.8
user 10.8
sys 0.0
time ./test-studio
Last crc was 6d0c33d0
real 14.6
user 14.6
sys 0.0
==
Note that this is the original crc.c with memcpy.