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]
Other format: [Raw text]

Optimization question


Isn't addressing (%ebx,%ecx,4) the same speed as -4(%ebx,%ecx,4)?
If so, then why does gcc (3.2) produce the following assembly
(using -O6):

.L1393:
        subl    $4, %edx
        decl    %ecx
        movl    (%edx), %eax
        xorl    (%ebx,%ecx,4), %eax
        testl   %ecx, %ecx
        movl    %eax, (%edx)
        jne     .L1393
 
An easy optimization of this code
would be:

.L1393:
        subl    $4, %edx
        movl    (%edx), %eax
        xorl    -4(%ebx,%ecx,4), %eax
        decl    %ecx
        movl    %eax, (%edx)
        jne     .L1393

Even faster would be imho

.L1393:
        subl    $4, %edx
        movl    (%edx), %eax
        xorl    -4(%ebx,%ecx,4), %eax
        movl    %eax, (%edx)
        loop    .L1393

I know that the emphasis of development hasn't been on
optimization, is it correct that this kind of optimization
can be expected in the near future?
  
-- 
Carlo Wood <carlo@alinoe.com>


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