https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92276
--- Comment #2 from Lijian Zhang <Lijian.Zhang at arm dot com> --- (In reply to Richard Biener from comment #1) > Instead of trying to force the compiler to unroll with -funroll-loops you can > use #pragma GCC unroll N on individual loops instead. > > The attributes should not conflict in any way. Sorry, I made a mistake that in my case '__attribute__ ((optimize("unroll-loops")))' should be used for the caller, not the callee. #pragma GCC optimize ("unroll-loops") is also working. Thanks for your suggestion! ///////////////////// #include <stdio.h> #include <stdlib.h> #include <arm_acle.h> static inline __attribute__ ((__always_inline__)) unsigned int clib_crc32c (unsigned int v, unsigned char * s, int len) { for (; len >= 8; len -= 8, s += 8) v = __crc32cd (v, *((unsigned long *) s)); for (; len >= 4; len -= 4, s += 4) v = __crc32cw (v, *((unsigned int *) s)); for (; len >= 2; len -= 2, s += 2) v = __crc32ch (v, *((unsigned short *) s)); for (; len >= 1; len -= 1, s += 1) v = __crc32cb (v, *((unsigned char *) s)); return v; } __attribute__ ((optimize("unroll-loops"))) int main (int argc, char *argv[]) { unsigned char s[40] = {argc, 0, argc, 0}; unsigned char ss[32] = {argc, 0, argc, 0, argc, 0}; unsigned int v = 0xbeefdead, vv = 0xdeadbeef; int len = strtol (argv[1], NULL, 10); v = clib_crc32c (v, s, 40); vv = clib_crc32c (vv, ss, 32); printf ("%8X\n", v); printf ("%8X\n", vv); return 0; }