This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improved signed integer remainder by power of two
- From: Falk Hueffner <hueffner at informatik dot uni-tuebingen dot de>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org,Steven Bosscher <stevenb at suse dot de>
- Date: Tue, 29 Jun 2004 01:06:49 +0200
- Subject: Re: [PATCH] Improved signed integer remainder by power of two
- References: <Pine.LNX.4.44.0406281419001.20524-100000@www.eyesopen.com>
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