1// Copyright 2016 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5#include "textflag.h"
6
7#define PosInf 0x7FF0000000000000
8#define NaN    0x7FF8000000000001
9#define NegInf 0xFFF0000000000000
10
11// func ·archMax(x, y float64) float64
12TEXT ·archMax(SB),NOSPLIT,$0
13	// +Inf special cases
14	MOVD	$PosInf, R0
15	MOVD	x+0(FP), R1
16	CMP	R0, R1
17	BEQ	isPosInf
18	MOVD	y+8(FP), R2
19	CMP	R0, R2
20	BEQ	isPosInf
21	// normal case
22	FMOVD	R1, F0
23	FMOVD	R2, F1
24	FMAXD	F0, F1, F0
25	FMOVD	F0, ret+16(FP)
26	RET
27isPosInf: // return +Inf
28	MOVD	R0, ret+16(FP)
29	RET
30
31// func archMin(x, y float64) float64
32TEXT ·archMin(SB),NOSPLIT,$0
33	// -Inf special cases
34	MOVD	$NegInf, R0
35	MOVD	x+0(FP), R1
36	CMP	R0, R1
37	BEQ	isNegInf
38	MOVD	y+8(FP), R2
39	CMP	R0, R2
40	BEQ	isNegInf
41	// normal case
42	FMOVD	R1, F0
43	FMOVD	R2, F1
44	FMIND	F0, F1, F0
45	FMOVD	F0, ret+16(FP)
46	RET
47isNegInf: // return -Inf
48	MOVD	R0, ret+16(FP)
49	RET
50