aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/floats.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/codegen/floats.go b/test/codegen/floats.go
index 3942cb5862..343f8fab39 100644
--- a/test/codegen/floats.go
+++ b/test/codegen/floats.go
@@ -6,6 +6,8 @@
package codegen
+import "math"
+
// This file contains codegen tests related to arithmetic
// simplifications and optimizations on float types.
// For codegen tests on integer types, see arithmetic.go.
@@ -277,3 +279,37 @@ func Float64ConstantStore(p *float64) {
// riscv64: "MOVD [$]f64.4015ba5e353f7cee"
*p = 5.432
}
+
+// ------------------------ //
+// Subnormal tests //
+// ------------------------ //
+
+func isSubnormal(x float64) bool {
+ // riscv64:"FCLASSD" -"FABSD"
+ return math.Abs(x) < 2.2250738585072014e-308
+}
+
+func isNormal(x float64) bool {
+ // riscv64:"FCLASSD" -"FABSD"
+ return math.Abs(x) >= 0x1p-1022
+}
+
+func isPosSubnormal(x float64) bool {
+ // riscv64:"FCLASSD"
+ return x > 0 && x < 2.2250738585072014e-308
+}
+
+func isNegSubnormal(x float64) bool {
+ // riscv64:"FCLASSD"
+ return x < 0 && x > -0x1p-1022
+}
+
+func isPosNormal(x float64) bool {
+ // riscv64:"FCLASSD"
+ return x >= 2.2250738585072014e-308
+}
+
+func isNegNormal(x float64) bool {
+ // riscv64:"FCLASSD"
+ return x <= -2.2250738585072014e-308
+}