3 ms·
Turbo C++ 3.0 from 1992 already does this optimization, according to a quick experiment over there: https://turboc.pages.dev/ https://turboc.pages.dev/
by fweimer 6mo ago
Turbo C++ 3.0 from 1992 already does this optimization, according to a quick experiment over there: https://turboc.pages.dev/ https://turboc.pages.dev/
0: 55 push %bp
1: 8b ec mov %sp,%bp
3: 8b 46 04 mov 0x4(%bp),%ax
6: c1 e0 02 shl $0x2,%ax
9: eb 00 jmp 0xb
b: 5d pop %bp
c: c3 ret
That's for:
int
main (int argc, char **argv)
{
return argc * 4;
}
And disassembled with contemporary binutils (not sure if Turbo C++ came with a disassembler.)