This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc optimization improvement?


Ralph Doncaster wrote:
> And I was thinking that the listed source is still not optimal.
> 
>         incl %edx                  # Increment i
>         cmpl %ecx,%edx   # Test i < j
>         jl .L5                           # Loop if i < j
> 
> if j is assigned to i (edx) before the loop, then couldn't the above be
> reduced to a decrement and branch if not zero?  (my old x86 assembly
> book is not handy, but I'm pretty sure there is a jne or something like
> that)

And if you need to _use_ i in the loop, as an address index, you can
sometimes assign -j to i, using a more complicated addressing mode
involving j and i together, and the loop test is increment and branch if
not zero.

enjoy,
-- Jamie

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]