Sujet : Re: Cray style vectors
De : terje.mathisen (at) *nospam* tmsw.no (Terje Mathisen)
Groupes : comp.archDate : 12. Mar 2024, 10:52:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <usp8lp$7i96$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18.1
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?
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?
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
-- - <Terje.Mathisen at tmsw.no>"almost all programming can be viewed as an exercise in caching"