Re: which code performs better
"joseph cook" <joecook@gmail.com>
Could you post the compiler settings and assy output plz?
Sure: Looks like it is making copies in f2. As I said, I don't
understand why at this point, so perhaps it is a compiler issue.
[code in original]
Interesting case... The first version uses the fact that the two source
objects live close together at known offset. in the second it assigned 2
variables, and lost that information. As references were defined, it could
go with a single register and address the other with offset.
Also look at this portion:
xorl %ebx, %ebx
leal -104(%ebp), %edi
xorl %ebx, %ebx
leal -104(%ebp), %edi
leal -184(%ebp), %esi
This us utter nonsense. (I see a ton of similar in my PIC output :-((((( )
The first two instructins are excess and should not be there at all in any
case.
This is the final set of esi and edi -- the optimizer could remember the
original and "inline" the original expression too.
This section:
leal 0(,%ebx,8), %eax
leal (%edi,%eax), %edx
movl (%edx), %ecx
leal (%esi,%eax), %eax
cmpl (%eax), %ecx
is utter nuts too -- with the code above it should just be something like
movl (%edi), %eax
cmpl (%esi), %eax
and then next occourance same with +2 offset.
Err, no, sorry, it is too late ;-) the issue is worse -- this nut did NOT
use esi and edi to hold values of reference x1 and x2, they hold yList1 and
xList1. Why on earth? so the code would be
movl (%edi, ebx, 8), %eax
cmpl (%esi, ebx, 8), %eax
even without inlining the original ebp expression.
or if it is obsessed to calc the offset in eax
leal 0(,%ebx,8), %eax
movl (%edi,%eax), %ecx
cmpl (%esi,%eax), %ecx
Generating those separate leal-s jsut to trash a register and waste an
instruction is nuts.
This unnecessary juggling with registers seem to be prevalent in gcc output,
and I rather stay with my opinion of "seriously broken", be it bold or not.