CPU実験室

誰も見向きもしない古いCPUをいじって動かしてみようというプロジェクトです

比較テスト(80386/gcc)

ずいぶん回り道をしましたが、本来やろうとしていたマンデルブロ集合計算の
スピードアップにたどり着きました。

まずは例によってmandel_chk()関数のコンパイル結果を見てみます
	.file	"man386.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
	.p2align 2
LC0:
	.long 0x0,0x40100000
	.p2align 2
.globl _mandel_chk
_mandel_chk:
	pushl %ebp
	movl %esp,%ebp
	fldl 8(%ebp)
	fldl 16(%ebp)
	fldz
	fld %st(0)
	movl $1,%ecx
	fldl LC0
	jmp L11
	.align 2,0x90
L16:
	fxch %st(2)
L11:
	fld %st(1)
	fmul %st(2),%st
	fld %st(3)
	fmul %st(4),%st
	fsubrp %st,%st(1)
	fadd %st(5),%st
	fld %st(2)
	faddp %st,%st(3)
	fxch %st(2)
	fmulp %st,%st(3)
	fxch %st(2)
	fsub %st(3),%st
	fld %st(1)
	fmul %st(2),%st
	fld %st(1)
	fmul %st(2),%st
	faddp %st,%st(1)
	fcomp %st(3)
	fnstsw %ax
	andb $69,%ah
	jne L12
	fstp %st(0)
	fstp %st(0)
	fstp %st(0)
	fstp %st(0)
	fstp %st(0)
	movl %ecx,%edx
	testl %ecx,%ecx
	jge L13
	leal 255(%ecx),%edx
L13:
	movzbl %cl,%eax
	jmp L15
	.align 2,0x90
L12:
	incl %ecx
	cmpl $8191,%ecx
	jle L16
	fstp %st(0)
	fstp %st(0)
	fstp %st(0)
	fstp %st(0)
	fstp %st(0)
	xorl %eax,%eax
L15:
	leave
	ret

こちらもx87命令をインラインで生成していてなかなか良さそう。

早速実行させました

イメージ 1


80387の稼働率をみると50%近くまで針が振れていて利用効率が上がっています

さて結果は・・・