This is the mail archive of the gcc-patches@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: [PATCH] Improved signed integer remainder by power of two


Roger Sayle <roger@eyesopen.com> writes:

> FYI, here's the patch with the above change that I intend to commit
> to mainline CVS shortly.

Interestingly, it makes x % 16 be one cycle longer and slower on Alpha:


old:    sra     a0,0x3f,t0
        srl     t0,0x3c,t0
        addq    a0,t0,t0
        andnot  t0,0xf,t0
        subl    a0,t0,v0
        ret

new:    sra     a0,0x3f,t0
        xor     a0,t0,v0
        subq    v0,t0,v0
        and     v0,0xf,v0
        xor     v0,t0,v0
        subl    v0,t0,v0
        ret

The DEC compiler simply uses a branch. Actually, I can very much see
that; nobody wants the silly semantics of % for negative operands, you
only use it on operands that will always be positive, so the branch
will always be predicted perfectly.

-- 
	Falk


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