COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### cycle count for divide

• Follow

```Suppose I want to divide an integer with another integer,
how many cycles does it take in general on PVI and PIII?
I notice that the output of a divide is usually float, does
that mean the divide is only for floats, meaning those
two operands got converted into float?

How expensive is modulo in terms of cycle count?

Cheers,
Jimmy

```
 0

```Jimmy zhang wrote:

> Suppose I want to divide an integer with another integer,
> how many cycles does it take in general on P4 and PIII?

IA-32 Optimization Reference Manual
Appendix C (IA-32 Instruction Latency and Throughput)

Signed integer division:
Northwood = 56-70 cycles
Prescott  = 66-80 cycles
Pentium M = undisclosed

I don't have the Pentium III latencies.

> I notice that the output of a divide is usually float, does
> that mean the divide is only for floats, meaning those
> two operands got converted into float?

??

Integer division of a by b produces two integers: q (the quotient)
and r (the remainder) such that a = b*q + r and 0 <= r < b

> How expensive is modulo in terms of cycle count?

Modulo 2^n is a simple bit mask operation. Otherwise, see above.

--
Regards, Grumble

```
 0

```"Jimmy zhang" <jzhang@ximpleware.com> wrote:

>Suppose I want to divide an integer with another integer,
>how many cycles does it take in general on PVI and PIII?
>...
>How expensive is modulo in terms of cycle count?

The integer division instruction produces two results: a quotient and a
remainder.  The modulo operation is, of course, the remainder of a
division.  So, the answer to your second question is exactly the same as
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

```
 0

```if the divisor equals 2^x, where x is an integer, does the cycle count
remains the same?

"Grumble" <a@b.c> wrote in message news:chhfbk\$c8\$1@news-rocq.inria.fr...
> Jimmy zhang wrote:
>
> > Suppose I want to divide an integer with another integer,
> > how many cycles does it take in general on P4 and PIII?
>
> IA-32 Optimization Reference Manual
> Appendix C (IA-32 Instruction Latency and Throughput)
>
> Signed integer division:
> Northwood = 56-70 cycles
> Prescott  = 66-80 cycles
> Pentium M = undisclosed
>
> I don't have the Pentium III latencies.
>
> > I notice that the output of a divide is usually float, does
> > that mean the divide is only for floats, meaning those
> > two operands got converted into float?
>
> ??
>
> Integer division of a by b produces two integers: q (the quotient)
> and r (the remainder) such that a = b*q + r and 0 <= r < b
>
> > How expensive is modulo in terms of cycle count?
>
> Modulo 2^n is a simple bit mask operation. Otherwise, see above.
>
> --
> Regards, Grumble
>

```
 0

```Jimmy zhang wrote:

> if the divisor equals 2^x, where x is an integer, does the cycle
> count remain the same?

In that case, you should use SHR instead of IDIV.

```
 0

```"Jimmy zhang"  <spamtrap@crayne.org> wrote in message news:<NaV_c.6697\$vy.1320@attbi_s52>...
> Suppose I want to divide an integer with another integer,
> how many cycles does it take in general on PVI and PIII?
> I notice that the output of a divide is usually float, does
> that mean the divide is only for floats, meaning those
> two operands got converted into float?
>
> How expensive is modulo in terms of cycle count?

It will depend on a number of factors. Assuming div reg32, m32 I think
it is 3 uops + 20 from microcode (on a netburst architecture) with
about a 50 cycle latency (if the next instruction is dependent). These
are, by necessity, only aproximate values. Agner.org and intel's
netburst documentation has some better details. Div, however, does not
return a float -- it returns 2 unsigned values (not quite the same
thing).

```
 0

5 Replies
366 Views

Similiar Articles:

7/23/2012 7:28:50 PM