From 102436e800d161dfd8b884278d1ddc5101f562dd Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Thu, 30 Apr 2015 19:03:31 -0400 Subject: runtime: fix software FP regs corruption when emulating SQRT on ARM When emulating ARM FSQRT instruction, the sqrt function itself should not use any floating point arithmetics, otherwise it will clobber the user software FP registers. Fortunately, the sqrt function only uses floating point instructions to test for corner cases, so it's easy to make that function does all it job using pure integer arithmetic only. I've verified that after this change, runtime.stepflt and runtime.sqrt doesn't contain any call to _sfloat. (Perhaps we should add //go:nosfloat to make the compiler enforce this?) Fixes #10641. Change-Id: Ida4742c49000fae4fea4649f28afde630ce4c576 Signed-off-by: Shenghou Ma Reviewed-on: https://go-review.googlesource.com/9570 Reviewed-by: Dave Cheney Reviewed-by: Keith Randall --- src/runtime/softfloat_arm.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/runtime/softfloat_arm.go') diff --git a/src/runtime/softfloat_arm.go b/src/runtime/softfloat_arm.go index 8f184ccf3b..4e97e13f1a 100644 --- a/src/runtime/softfloat_arm.go +++ b/src/runtime/softfloat_arm.go @@ -437,8 +437,7 @@ stage3: // regd, regm are 4bit variables break case 0xeeb10bc0: // D[regd] = sqrt D[regm] - uval = float64bits(sqrt(float64frombits(fgetd(regm)))) - fputd(regd, uval) + fputd(regd, sqrt(fgetd(regm))) if fptrace > 0 { print("*** D[", regd, "] = sqrt D[", regm, "] ", hex(m.freghi[regd]), "-", hex(m.freglo[regd]), "\n") -- cgit v1.3