[comp.sys.misc] 386 vs 387 integer divide performance

6600m00n@ucsbuxa.ucsb.edu (Jihad 'R US) (10/11/90)

   From: jde@Unify.Com (Jeff Evarts)
  
   Netters,
	   I have a question, err one question in two parts.

	   Suppose I have some 32  bit INTEGER division to do, and I am
	   running on a system with a 386 with a 387. A quick look at my
	   manuals seems to indicate the following timings:

		   386: 46-49 cycles
		   387: 88-127 cycles

	   1. Am I missing something obvious, or wouldn`t the 386 be the
	      faster of the two? I _understand_ that the 387 is an FP machine,
	      but I had thought that it might have some nifty tricks or
	      optimized hardware to do the job in less time.


The 386 is faster for integer division, because it does not have to deal
with any of the floating point details.  Also, cycle counts also depend
on the operands of you rdivisions.  Dividing 32 bits by 16 takes 27-30
64 by 32 takes 43-46, 16 by 8 takes 19-22.  on the floating point
side, stack(0) by integer takes 120-127 cycles on the 387.  The integer 
chip wins for integer division.   Also, floating point division does not
give integral answers, so one must convert back to integers. (79-93)

	   2. If I have got it right, and the 386 is the faster engine, does
	      this change for a 486?

If my memory serves me, the 486 can be faster for some operations using
floats, but the general rule is to use the instruction type ( int,
float) that fits the problem best.  

( I got this information out of the book Programming the 80386, by
John Crawford and Patric Gelsinger.  Useful book, includes _detailed_ 
timing specs, and tons of examples, etc)

   Thanks in Advance,

   -Jeff Evarts
   --jde@unify.COM
   ---{sequent|pyramid|csusac}!unify!jde
   #include <std.disclaimer>

Hope this helps,
Rob.
6600m00n@ucsbuxa.ucsb.edu
( and remember, shld, and lea are your assembly friends!)

seanf@sco.COM (Sean Fagan) (10/12/90)

In article <qbc13ys@Unify.Com> jde@Unify.Com (Jeff Evarts) writes:
>		386: 46-49 cycles
>		387: 88-127 cycles
>
>	1. Am I missing something obvious, or wouldn`t the 386 be the
>	   faster of the two? 

Yes, you're missing something obvious, and, yes, the '386 is the faster of
the two.  The 'something obvious' you're missing is that the '387 has to do
the divide as an 80-bit number, regardless of the precision you're
interested in.

>	2. If I have got it right, and the 386 is the faster engine, does
>	   this change for a 486?

Probably not, since the divide for the '486 is faster than the '386.

-- 
-----------------+
Sean Eric Fagan  | "*Never* knock on Death's door:  ring the bell and 
seanf@sco.COM    |   run away!  Death hates that!"
uunet!sco!seanf  |     -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor")
(408) 458-1422   | Any opinions expressed are my own, not my employers'.