3 ms·
The division case is optimized for size. The code for using a division instruction is smaller than the code for a shift followed by the magic to make it well be
by nwallin 7y ago
The division case is optimized for size. The code for using a division instruction is smaller than the code for a shift followed by the magic to make it well behaved for negative integers. So it uses the division instruction.
In general, always use -O2. -Os is only a good idea if you're on embedded and a -Os program fits in memory and -O2 doesn't. There really aren't any other cases where -Os is better.