Compiler optimizations

Craig Black cblack at ara.com
Sun Apr 30 06:10:09 PDT 2006


"dennis luehring" <dl.soluz at gmx.net> wrote in message
news:e32c0m$1dsu$1 at digitaldaemon.com...
> > Another thing.  I know that integer division is essentially a floating
point
> > operation because there is no integer division instruction.
>
> and what is "idiv" for you?
> (http://www.jegerlehner.ch/intel/opcode.html)

Please anyone, correct me if I'm wrong, but I think IDIV is a
pseudo-instruction.  80x86 is notorious for those (as opposed to RISC).  I
read on the Intel website that intel processors do not have a hardware
integer division instruction.  Apparently it is somehow better to use the
floating point instruction instead.

The benchmarks that I've done are constistent with this.  I found it was
faster to perform a floating-point multiplication on an integer and then
convert it back to an integer than just a single integer division.

>
> > I also read
> > some on the internet and learned that Intel has a library that provides
> > fixed-point math routines, which provides a division operation that
> > outperforms floating-point division.  Then I thought to myself, "Why
don't
> > compilers just use fixed-point division for dividing integers since it's
> > faster?"
>
> a fixpoint floating somethimes outperforms an floating-point operating
> (with loss of precession)
>
> but it never outperforms an true integer division
>
> ciao dennis

Have you run benchmarks?

-Craig





More information about the Digitalmars-d mailing list