Sujet : Re: Cray style vectors
De : mitchalsup (at) *nospam* aol.com (MitchAlsup1)
Groupes : comp.archDate : 12. Mar 2024, 18:13:38
Autres entêtes
Organisation : Rocksolid Light
Message-ID : <fcea0650cf69a0f092d64d699ca21acc@www.novabbs.org>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Rocksolid Light
Terje Mathisen wrote:
Tim Rentsch wrote:
Terje Mathisen <terje.mathisen@tmsw.no> writes:
If I really had to write a 64x64->128 MUL, with no widening MUL or
MULH which returns the high half, then I would punt and do it using
32-bit parts (all variables are u64): [...]
I wrote some code along the same lines. A difference is you
are considering unsigned multiplication, and I am considering
signed multiplication.
Signed mul is just a special case of unsigned mul, right?
The low order N bits are all the same while the higher order N bits
are different; where N is operand size.
I.e. in case of a signed widening mul, you'd first extract the signs, convert the inputs to unsigned, then do the unsigned widening mul, before finally resotirng the sign as the XOR of the input signs?
SW may have to do that, HW does not.
There is a small gotcha if either of the inputs are of the 0x80000000 form, i.e. MININT, but the naive iabs() conversion will do the right thing by leaving the input unchanged.
At the other end there cannot be any issues since restoring a negative output sign cannot overflow/fail.
Terje