# sh testcase for fsqrt -*- Asm -*-
# mach: all
# as: -isa=shcompact
# ld: -m shelf32

	.include "compact/testutils.inc"

	start

	# sqrt(0.0) = 0.0.
	fldi0 fr0
	fsqrt fr0
	fldi0 fr1
	fcmp/eq fr0, fr1
	bf wrong

	# sqrt(1.0) = 1.0.
	fldi1 fr0
	fsqrt fr0
	fldi1 fr1
	fcmp/eq fr0, fr1
	bf wrong

	# sqrt(4.0) = 2.0
	fldi1 fr0
	# Double it.
	fadd fr0, fr0
	# Double it again.
	fadd fr0, fr0
	fsqrt fr0
	fldi1 fr1
	# Double it.
	fadd fr1, fr1
	fcmp/eq fr0, fr1
	bf wrong

	bra double
	nop

wrong:
	fail

double:
	# sqrt(0.0) = 0.0.
	fldi0 fr0
	_s2d fr0, dr0
	_setpr
	fsqrt dr0
	_clrpr
	fldi0 fr2
	_s2d fr2, dr2
	_setpr
	fcmp/eq dr0, dr2
	bf wrong2
	_clrpr

	# sqrt(1.0) = 1.0.
	fldi1 fr0
	_s2d fr0, dr0
	_setpr
	fsqrt dr0
	_clrpr
	fldi1 fr2
	_s2d fr2, dr2
	_setpr
	fcmp/eq fr0, fr2
	bf wrong2
	_clrpr

	# sqrt(4.0) = 2.0.
	fldi1 fr0
	# Double it.
	fadd fr0, fr0
	# Double it again.
	fadd fr0, fr0
	_s2d fr0, dr0
	_setpr
	fsqrt dr0
	_clrpr
	fldi1 fr2
	# Double it.
	fadd fr2, fr2
	_s2d fr2, dr2
	_setpr
	fcmp/eq fr0, fr2
	bf wrong2
	_clrpr

okay:
	pass

wrong2:
	fail
