[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Re: GCC



>  L14:
> >         addl d3,a1@(d0:l)       ; 3 instructions with the second compiler
> >         addql #4,d0             ;  but then this isn't needed instead
> >         addql #1,d1
> >         moveq #24,d5
> >         cmpl d1,d5
> >         jge L14
...
> > The '24' is still loaded in every iteration of the loop for some reason.
> > I don't know why the compilers don't realize that neither d1 nor d5 are
> > used in the loop. The strength reduction should tell it that it can
> > remove them completely or use for example a dbra.
> > 
> > Speed and size!
> moveq is only 2 bytes and very fast.

I know that, but what I'm saying is that you could move it outside the
loop (that is, do it before L14), since d5 is never modified.

> You could turnaround the jge and save 1 instr
> cmpl #24,d1
> jlt L14
> But his is slower and bigger

Actually, it should be faster on an '040.


What the compiler should have done is simply

    moveq   #24,d5
L14:
    add.l   d3,(a1,d0.l)
    addq.l  #4,d0 
    addq.l  #1,d1
    cmp.l   d1,d5
    bge     L14

or better

    moveq   #24,d5
L14:
    add.l   d3,(a1,d0.l)
    addq.l  #4,d0
    dbra    d5,L14

or even

    moveq   #24,d5
L14:
    add.l   d3,(a1)+
    dbra    d5,L14

but the latter would require changes elsewhere too.

> #24 is a 32 bit long immediate following the 2 byte instr.
> 
> And because of plenty free regs the compiler could do this

I have no problem with it allocating a register for a constant number.
It should remember that it has already done it, however.

> The compiler didnt overlook d5, no it deliberately allocated d5
> gcc maybe be better than you think. :-)

I have a rather high opinion of gcc, but see above.

-- 
  Chalmers University   | Why are these |  e-mail:   rand@cd.chalmers.se
     of Technology      |  .signatures  |            johan@rand.thn.htu.se
                        | so hard to do |  WWW/ftp:  rand.thn.htu.se
   Gothenburg, Sweden   |     well?     |            (MGIFv5, QLem, BAD MOOD)