4 ms·
Wouldn't -Os optimize for size better than hand-crafted ASM? Genuine question.
by haolez 5y ago
Wouldn't -Os optimize for size better than hand-crafted ASM? Genuine question.
- deleted 5y ago[deleted]
- userbinator 5y agoMy experience is mostly with x86, where the answer is a definitive "no"; for ARM, my guess is "likely no" --- it's a RISC, so instruction selection isn't as critical, and all instructions are fixed-width so again there isn't as much flexibility in instruction selection (e.g. in x86 a "xor reg, reg" is the canonical way to zero a register, and explicit loading with a constant 0 is very much discouraged and a few bytes bigger, even compilers know about that now.) That said, I've also seen compilers do ridiculous stupid things which no human ever would.
- MaxLeiter 5y agoCant speak much for x86, but for many older / less common architectures (I can speak for z80) the compilers aren’t as advanced or are missing extensive optimizations.