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]

Re: [tree-ssa] count-branch-reg optimization


In message <F059E17E-87DD-11D7-894C-000393A6D2F2@physics.uc.edu>, Andrew Pinski
 writes:
 >
 >--Apple-Mail-7--351795578
 >Content-Transfer-Encoding: 7bit
 >Content-Type: text/plain;
 >	charset=US-ASCII;
 >	format=flowed
 >
 >Is there a way get this optimization working on the ssa branch, it 
 >seems like it is broken because of the rtl that is written out from the 
 >trees.
 >
 >For an example:
 >void temp(int limit, char *x)
 >{
 >         int i;
 >         for(i=0;i<limit;i++)
 >         {
 >                 x[i] = 0;
 >         }
 >}
 >
 >On PPC on the mainline, it produces:
 >_temp:
 >         li r2,0
 >         cmpw cr0,r2,r3
 >         bgelr- cr0
 >         mtctr r3
 >         li r0,0
 >L8:
 >         stbx r0,r4,r2
 >         addi r2,r2,1
 >         bdnz L8
 >         blr
 >
 >But using the ssa-branch it produces:
 >
 >_temp:
 >         li r2,0
 >         li r0,0
 >         cmpw cr0,r2,r3
 >         bgelr- cr0
 >L8:
 >         stbx r0,r4,r2
 >         addi r2,r2,1
 >         cmpw cr0,r2,r3
 >         bgelr- cr0
 >         b L8
 >
 >One on the mainline is faster by about 2x.
FWIW, tree-ssa generates the following code for you loop these days:


 >temp:
        mr. 0,3
        mtctr 0
        blelr- 0
        li 9,0
        li 0,0
.L5:
        stbx 0,4,9
        addi 9,9,1
        bdnz .L5
        blr

Note the use of bdnz :-)

jeff


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