Open Bug 605933 Opened 14 years ago Updated 8 months ago

IonMonkey: Division by Constant Double

Categories

(Core :: JavaScript Engine, enhancement)

x86
Windows XP
enhancement

Tracking

()

People

(Reporter: evilpie, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [ion:t])

After Division by Constant for NanoJit didnt work out yet, i tried out my approach for double division.

Double division can be rewritten to 2x multiplications and 1x add, if the divisor is in some parameters. See http://hal.inria.fr/docs/00/08/74/65/PDF/DivIEEETC-aug04.pdf and http://lara.inist.fr/bitstream/2332/801/1/LIP-RR2002-30.pdf.

I didn't implement the check yet, but did try out rewriting the expression.

a = 2;
b = 3.2;

for (i = 0; i <= 1000000; i++) {
  c = a / b;
}

This goes down from about 13~15 to about ~5, without losing precision.
Pastebin of approach: http://pastebin.mozilla.org/822613
Interesting. I wonder how frequently this happens in real code.
I went through the benchmark, but there seems to be no! use of division by constant with double. I will try to check modulo next, this should bring definite win!
Is this a dup of bug 600459?
Is this bug useful for JM too?
Maybe it's useful for IM, not sure yet.
Summary: TM: Division by Constant Double → IonMonkey: Division by Constant Double
Assignee: general → nobody
Severity: normal → S3
Blocks: sm-jits
Type: defect → enhancement
You need to log in before you can comment on or make changes to this bug.