Path: chuka.playstation.co.uk!news From: sosman@terratron.com (Steven Osman) Newsgroups: scee.yaroze.freetalk.english Subject: Re: Daft Question [long] Date: Sun, 02 Sep 2001 15:34:23 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 53 Message-ID: <3b9250e6.158216893@www.netyaroze-europe.com> References: <9lrqqf$3j63@www.netyaroze-europe.com> <01c129ca$a5a6f700$d81fe4d5@pal-s-omnibook> <9m1d9c$b2i7@www.netyaroze-europe.com> <01c12ceb$fba64880$9709e4d5@pal-s-omnibook> <9m9c88$ioj5@www.netyaroze-europe.com> <01c12edc$cc2bf440$991fe4d5@pal-s-omnibook> <9me1g1$1sb13@www.netyaroze-europe.com> <9meajl$1sb17@www.netyaroze-europe.com> <01c13018$85386ae0$122e1bd4@pal-s-omnibook> <9mjelr$dra1@www.netyaroze-europe.com> <9mrotl$mfo3@www.netyaroze-europe.com> NNTP-Posting-Host: dsl092-099-074.nyc2.dsl.speakeasy.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 ...but isn't this how the ALU performs multiplication internally? I mean -- when you say y*6, the number 6 itself is 110 in binary (notice, the "2" bit is 1, the "1" bit is 1, and the "0" bit is 0) -- so you take y, shift it by 2, add it, shift it by 1 add it, etc, etc... Remember that the processor can take UP TO 32 cycles... presumably, that would be if it has to do a tonne of additions -- i.e. if the multiplier has all 1's in it... But I don't know the MIPS processor that intimately... Sauce On Sat, 1 Sep 2001 23:52:59 +0100, "John \( QuietBloke \)" wrote: >On a similar note... if a mul can can up to 32 cycles then presumably >something like x=y*6 would be faster if coded as x=y+y+y<<2 or maybe even >x=y<<2+y<<1 would be faster still. Would a compiler do this on max >optimization too ? > >"Jon Prestidge (Jon@surfed.to)" wrote in message >news:9mjelr$dra1@www.netyaroze-europe.com... >> It probably is if you've seen it I was just guessing... I never noticed a >> big difference in clock cycle useage with other processors between >different >> operations-- mind you I've never looked too closely, and they weren't >risc. >> I certainly never knew there was a co processor like Alex says so ignore >> most of what I said John >> >> > all arithmetic and logic >> > operations take one cycle except for >> > muls and divs which can take up to >> > about 32 cycles. >> >> ... that's interesting....so 5+5+5+5+5+5 is qucker that 5*6 for example. >> ....although I suppose it'd have to fether the instructions too so perhaps >> not. I surprised that all the other instructions only take one cycle, I >> guess that's risc. I was guessing something like a logical shift would >take >> about 4 cycles and divide would take about 6, how wrong I was--- well >that's >> opened my eyes, I'll beable to optimise my code better now, cheers. >> >> >> Jon >> >> >> >