@asuffield said:
You would indeed be surprised as just how bad the pre-ssa dataflow code was. 4.0 replaced a system that's about 10 years old with a modern one (thankfully, that's almost the last of the disastrously obsolete code eliminated). I can't be bothered to root out an old copy of gcc and find out if it actually could figure out this particular case, but it used to have great difficulty with non-trivial code motion/constant folding optimisations.
int main(void)
{
9a0: 53 push %rbx
int foo = 1024;
float bar;
bar = foo * 2;
foo = (4 >> 1) * (foo * foo);
foo %= (int)(bar * 3);
bar -= foo / bar;
foo *= bar;
printf("%d\n", foo);
9a1: 48 8d 3d 34 01 00 00 lea 308(%rip),%rdi
9a8: be 00 f8 3f 00 mov $0x3ff800,%esi # 4192256
9ad: 48 83 ec 10 sub $0x10,%rsp
9b1: 48 8b 1d 30 06 10 00 mov 1050160(%rip),%rbx
9b8: 48 8b 03 mov (%rbx),%rax
9bb: 48 89 04 24 mov %rax,(%rsp)
9bf: 31 c0 xor %eax,%eax
9c1: e8 c2 fe ff ff callq 888 <printf@plt>
gcc (GCC) 3.4.6 (Gentoo Hardened 3.4.6-r2 p1.5, ssp-3.4.6-1.0, pie-8.7.10)
int main(void)
{
100003d4: 94 21 ff f0 stwu r1,-16(r1)
100003d8: 7c 08 02 a6 mflr r0
100003dc: 90 01 00 14 stw r0,20(r1)
int foo = 1024;
float bar;
bar = foo * 2;
foo = (4 >> 1) * (foo * foo);
foo %= (int)(bar * 3);
bar -= foo / bar;
foo *= bar;
printf("%d\n", foo);
100003e0: 3c 60 10 00 lis r3,4096
100003e4: 3c 80 00 3f lis r4,63 # r4 = 16
100003e8: 38 63 06 0c addi r3,r3,1548
100003ec: 60 84 f8 00 ori r4,r4,63488 # 63488 | (r4 << 16) = 4192256
100003f0: 4c c6 31 82 crclr 4*cr1+eq
100003f4: 48 00 01 4d bl 10000540 <init_dummy+0x20>
GCC 2.95.3 on PPC