This should fix the slowdown from the previous patch, while
maintaining correct output. It speeds things up by about 15% for me,
using JIT on x86.
--- mandelbrot.pir 2005-12-23 02:50:52.000000000 -0500
+++ mandelbrot-opt.pir 2005-12-23 03:15:53.000000000 -0500
@@ -68,15 +68,14 @@
Ci -= 1
i = 0
-IREDO:
# Tr = Zr*Zr - Zi*Zi + Cr;
$N1 = Zr * Zr
$N2 = Zi * Zi
+IREDO:
Tr = $N1 - $N2
Tr += Cr
# Ti = 2*Zr*Zi + Ci;
- Ti = 2
- Ti *= Zr
+ Ti = 2 * Zr
Ti *= Zi
Ti += Ci
# Zr = Tr; Zi = Ti;
@@ -85,13 +84,13 @@
# if (Zr*Zr+Zi*Zi > limit*limit) break;
$N1 = Zr * Zr
$N2 = Zi * Zi
- $N1 += $N2
- if $N1 > limit goto IBRK
+ $N3 = $N1 + $N2
+ if $N3 > limit goto IBRK
inc i
if i < iter goto IREDO
IBRK:
byte_acc <<= 1
- if $N1 <= limit goto SLA
+ if $N3 <= limit goto SLA
byte_acc |= 0
goto SLE
SLA: byte_acc |= 1