This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC beaten by ICC in stupid trig test!
Zdenek Dvorak wrote:
doing what? I do not see any loop related optimization here.
Hi Zdenek. What is doing "the trick" (sorry for my informal words) on the
gcc-lno branch is -ftree-loop-optimize, *not* -funroll-loops.
When -ftree-loop-optimize is passed, the trigonometric computation (doit)
is moved outside of the loop, this is the complete result:
08048450 <main>:
8048450: 55 push %ebp
8048451: d9 e8 fld1
8048453: 89 e5 mov %esp,%ebp
8048455: 83 ec 18 sub $0x18,%esp
8048458: 83 e4 f0 and $0xfffffff0,%esp
804845b: 83 ec 10 sub $0x10,%esp
804845e: dd 1c 24 fstpl (%esp)
8048461: e8 aa ff ff ff call 8048410 <doit>
8048466: d9 ee fldz
8048468: 31 c0 xor %eax,%eax
804846a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
8048470: 40 inc %eax
8048471: d8 c1 fadd %st(1),%st
8048473: 3d 00 e1 f5 05 cmp $0x5f5e100,%eax
8048478: 75 f6 jne 8048470 <main+0x20>
804847a: dd d9 fstp %st(1)
804847c: dd 5c 24 04 fstpl 0x4(%esp)
8048480: c7 04 24 98 85 04 08 movl $0x8048598,(%esp)
8048487: e8 a4 fe ff ff call 8048330 <_init+0x48>
804848c: c9 leave
804848d: 31 c0 xor %eax,%eax
804848f: c3 ret
Whereas, without -ftree-loop-optimize, we have:
08048450 <main>:
8048450: 55 push %ebp
8048451: d9 ee fldz
8048453: 89 e5 mov %esp,%ebp
8048455: 53 push %ebx
8048456: 83 ec 24 sub $0x24,%esp
8048459: bb ff e0 f5 05 mov $0x5f5e0ff,%ebx
804845e: dd 5d f0 fstpl 0xfffffff0(%ebp)
8048461: 83 e4 f0 and $0xfffffff0,%esp
8048464: 83 ec 10 sub $0x10,%esp
8048467: eb 09 jmp 8048472 <main+0x22>
8048469: 8d b4 26 00 00 00 00 lea 0x0(%esi),%esi
8048470: dd d8 fstp %st(0)
8048472: c7 04 24 00 00 00 00 movl $0x0,(%esp)
8048479: b8 00 00 f0 3f mov $0x3ff00000,%eax
804847e: 89 44 24 04 mov %eax,0x4(%esp)
8048482: e8 89 ff ff ff call 8048410 <doit>
8048487: dc 45 f0 faddl 0xfffffff0(%ebp)
804848a: 4b dec %ebx
804848b: dd 55 f0 fstl 0xfffffff0(%ebp)
804848e: 79 e0 jns 8048470 <main+0x20>
8048490: dd 5c 24 04 fstpl 0x4(%esp)
8048494: c7 04 24 b8 85 04 08 movl $0x80485b8,(%esp)
804849b: e8 90 fe ff ff call 8048330 <_init+0x48>
80484a0: 8b 5d fc mov 0xfffffffc(%ebp),%ebx
80484a3: 31 c0 xor %eax,%eax
80484a5: c9 leave
80484a6: c3 ret
Perhaps it's ok moving doit even when -ffast-math is not passed, I don't
know for sure, honestly...
Thanks for your feedback,
Paolo.