#include <stdint.h> #include <stddef.h> /** * Name: CRC-32/MPEG-2 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1 * Poly: 0x4C11DB7 * Init: 0xFFFFFFF * Refin: False * Refout: False * Xorout: 0x0000000 * Note: */ uint32_t crc32(const uint8_t *data, size_t length) { uint8_t i; uint32_t crc = 0xffffffff; // Initial value while (length--) { crc ^= (uint32_t)(*data++) << 24; for (i = 0; i < 8; ++i) { if (crc & 0x80000000) crc = (crc << 1) ^ 0x04C11DB7; else crc <<= 1; } } return crc; }
For this code, the Os/Oz option results in generating larger code than O3.
https://godbolt.org/z/MEqqK1q5T
Section size for -Os options
```
| .text | .data | .bss | .rodata |
| 44(+0) | 0(+0) | 0(+0) | 1024(+0) |
```Section size for -O3 options```
| 104(+0) | 0(+0) | 0(+0) | 0(+0) |
The behavior is normal on gcc 10.3.1.
Hi,
Thanks for the report. I've committed a fix for this in commit 26e88fe809de0f1a1812c99e2e0106afb03257b3 and it'll be in GCC 15.3.