]> Cypherpunks repositories - gostls13.git/commitdiff
math: remove riscv64 assembly implementations of rounding
authorJorropo <jorropo.pgm@gmail.com>
Sat, 6 Jul 2024 02:48:04 +0000 (04:48 +0200)
committerGopher Robot <gobot@golang.org>
Wed, 10 Jul 2024 03:19:58 +0000 (03:19 +0000)
Fixes #68322

This reverts commit ad377e906a8ee6f27545d83de280206dacec1e58.

Change-Id: Ifa4811e2c679d789cc830dbff5e50301410e24d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/596516
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Commit-Queue: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/math/floor_asm.go
src/math/floor_noasm.go
src/math/floor_riscv64.s [deleted file]
test/fixedbugs/issue68322.go [new file with mode: 0644]

index 5cb45f5a7e84e16f1e08884892c95293fd131d79..fb419d6da2f6bfc98fcf8d12a82b39dc987f86d0 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build 386 || amd64 || arm64 || ppc64 || ppc64le || riscv64 || s390x || wasm
+//go:build 386 || amd64 || arm64 || ppc64 || ppc64le || s390x || wasm
 
 package math
 
index 6754ca8fc806e18cba71cd55c913175468472fad..5641c7ea0a49caf563cf496e2be234612dd0d2c8 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !386 && !amd64 && !arm64 && !ppc64 && !ppc64le && !riscv64 && !s390x && !wasm
+//go:build !386 && !amd64 && !arm64 && !ppc64 && !ppc64le && !s390x && !wasm
 
 package math
 
diff --git a/src/math/floor_riscv64.s b/src/math/floor_riscv64.s
deleted file mode 100644 (file)
index 62ce963..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "textflag.h"
-
-#define PosInf 0x7FF0000000000000
-
-// The rounding mode of RISC-V is different from Go spec.
-
-#define ROUNDFN(NAME, MODE)    \
-TEXT NAME(SB),NOSPLIT,$0;      \
-       MOVD    x+0(FP), F0;    \
-       /* whether x is NaN */; \
-       FEQD    F0, F0, X6;     \
-       BNEZ    X6, 3(PC);      \
-       /* return NaN if x is NaN */; \
-       MOVD    F0, ret+8(FP);  \
-       RET;                    \
-       MOV     $PosInf, X6;    \
-       FMVDX   X6, F1;         \
-       FABSD   F0, F2;         \
-       /* if abs(x) > +Inf, return Inf instead of round(x) */; \
-       FLTD    F1, F2, X6;     \
-       /* Inf should keep same signed with x then return */;   \
-       BEQZ    X6, 3(PC); \
-       FCVTLD.MODE     F0, X6; \
-       FCVTDL  X6, F1;         \
-       /* rounding will drop signed bit in RISCV, restore it */; \
-       FSGNJD  F0, F1, F0;     \
-       MOVD    F0, ret+8(FP);  \
-       RET
-
-// func archFloor(x float64) float64
-ROUNDFN(·archFloor, RDN)
-
-// func archCeil(x float64) float64
-ROUNDFN(·archCeil, RUP)
-
-// func archTrunc(x float64) float64
-ROUNDFN(·archTrunc, RTZ)
diff --git a/test/fixedbugs/issue68322.go b/test/fixedbugs/issue68322.go
new file mode 100644 (file)
index 0000000..9b3e713
--- /dev/null
@@ -0,0 +1,17 @@
+// run
+
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "math"
+
+var doNotFold = 18446744073709549568.0
+
+func main() {
+       if math.Trunc(doNotFold) != doNotFold {
+               panic("big (over 2**63-1) math.Trunc is incorrect")
+       }
+}