Text file src/math/hypot_loong64.s

     1  // Copyright 2026 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  
    10  // func archHypot(p, q float64) float64
    11  TEXT ·archHypot(SB),NOSPLIT,$0
    12  	MOVD	p+0(FP), F0
    13  	MOVD	q+8(FP), F1
    14  
    15  	MOVV	$1, R4
    16  	MOVV	R4, F9
    17  	FCLASSD	F0, F4
    18  	FCLASSD	F1, F5
    19  
    20  	ABSD	F0, F0
    21  	ABSD	F1, F1
    22  	MOVV	F4, R4
    23  	MOVV	F5, R5
    24  	DIVD	F9, F9, F7	// F7 = 1.0
    25  	SUBD	F7, F7, F4	// F4 = 0.0
    26  	OR	R4, R5, R6
    27  
    28  	// +Inf special case
    29  	AND	$68, R6, R7
    30  	BNE	R7, isInf
    31  
    32  	// NaN special case
    33  	AND	$2, R6, R8
    34  	BNE	R8, isNaN
    35  
    36  	// hypot = max * sqrt(1 + (min/max)**2)
    37  	FMAXD	F0, F1, F5
    38  	FMIND	F0, F1, F2
    39  	CMPEQD	F5, F4, FCC0
    40  	BFPT	isZero
    41  
    42  	DIVD	F5, F2, F4
    43  	FMADDD	F7, F4, F4, F4
    44  
    45  	SQRTD	F4, F4
    46  	MULD	F5, F4, F4
    47  	MOVD	F4, ret+16(FP)
    48  	RET
    49  isNaN:
    50  	MOVV	$NaN, R7
    51  	MOVV	R7, ret+16(FP)	// return NaN
    52  	RET
    53  isInf:
    54  	MOVV	$PosInf, R6
    55  	MOVV	R6, ret+16(FP)	// return +Inf
    56  	RET
    57  isZero:
    58  	MOVV	R0, ret+16(FP)	// return 0
    59  	RET
    60  

View as plain text