[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [f-cpu] signed cmpl
On Mon, Dec 16, 2002 at 10:41:00AM +0100, devik wrote:
> Hi,
>
> when I was adding conditionals into gcc code I found
> that signed compare is often used by gcc backend
> (more than unsigned one for most of code).
>
> IMHO the signed compare can be (even for SIMD) done as:
>
> xor.N a0,a1,t0 // get sign difference
> cmpl[e].N a0,a1,t1 // unsigned compare
> shiftari.N N-1,t0,t0 // convert MSB bit to negation mask
> // free slot here
> xor.N t0,t1,t0 // negate result for different signs
> it is 6 cycle latency! Can some HW guy here tell whether can
> I count on signed cmp being computed by INC unit too ? It
> would be one xor gate in its critical path AFAIK (negate
> result if sign bits were different).
My version would be:
[s]bchg.N N-1, a0, t0 // change sign(s)
[s]bchg.N N-1, a1, t1 // change sign(s)
// free slot
[s]cmpl[e].N t0, t1, t0 // unsigned compare
but that's hardly faster. However, it's easy to realize in hardware:
The unsigned cmpl is equivalent to
y = (first_bit(a ^ b) & b) ? -1 : 0
and its signed counterpart will be
y = (first_bit(a ^ b) & change_sign(b)) ? -1 : 0
which also needs a single XOR per chunk - but that's located *outside* the
critical datapath, because first_bit() takes more time than a single XOR.
Of course there will be both signed and unsigned integer compare
instructions (and also min/max/sort). Projected names for the signed
counterparts are cmpls, cmples, mins, maxs and minmaxs (aka sorts).
--
Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
"All I wanna do is have a little fun before I die"
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu in the body. http://f-cpu.seul.org/