Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.arch Subject: Re: RISC integer multiply/divide (was Re: Snake) Message-ID: <3276@charon.cwi.nl> Date: 6 Apr 91 20:42:34 GMT Article-I.D.: charon.3276 References: <9538@mentor.cc.purdue.edu> <1991Apr4.213550.8106@bingvaxu.cc.binghamton.edu> <1991Apr5.191136.21806@bingvaxu.cc.binghamton.edu> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 41 In article <1991Apr5.191136.21806@bingvaxu.cc.binghamton.edu> kym@bingvaxu.cc.binghamton.edu (R. Kym Horsell) writes: > Various people have responded via email regarding the ``3-multiply > trick''. Eh, yup. > > Mostly the feeling is that any extra trouble required by the method is > not worth the results. I must concur in the majority of cases. However, > we can ask the converse question ``on which architectures will the trick > work?'' As I indicated in a previous post, I had in mind DSP-type > chips that have fancy multiply-and-add and add-and-shift instructions. Might be, however, it is better to have correct code than fast code. Moreover, I see you changed from signed multiply to unsigned multiply. > > The Sparc would therefore be a good architecture to use the trick on. Barely. 33 multiply step instructions give you the 64 bits result. > > Running the benchmark on a Sun SS1 we have the output: > > 3700550176 3700550176 I found this quite interesting. Both umul3 and umul4 gave the same incorrect result for both cases I tried! > mid=bd+ac+(bd>>SHORTBITS); This can fail. 0 <= a,b,c,d < 2^16, so 0 <= mid < 2^33+2^16. You do not handle the overflow. Try: umul3(0xffffffff,0xffffffff) and see that it returns 0xfffe000000000001; not entirely correct. This is probably due to some glaring (and some subtle) bugs. > for(n=0; n sum4+=umul4(x[it],y[it])->hi; > } You want to change both occurrences of 'it' to 'n'. Same a bit further down. Bottom line, never compare apples with oranges, and certainly not rotten apples with rotten oranges. -- dik t. winter, cwi, amsterdam, nederland dik@cwi.nl