...

Text file src/math/hypot_amd64.s

Documentation: math

     1// Copyright 2010 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
    11TEXT ·archHypot(SB),NOSPLIT,$0
    12	// test bits for special cases
    13	MOVQ    p+0(FP), BX
    14	MOVQ    $~(1<<63), AX
    15	ANDQ    AX, BX // p = |p|
    16	MOVQ    q+8(FP), CX
    17	ANDQ    AX, CX // q = |q|
    18	MOVQ    $PosInf, AX
    19	CMPQ    AX, BX
    20	JLE     isInfOrNaN
    21	CMPQ    AX, CX
    22	JLE     isInfOrNaN
    23	// hypot = max * sqrt(1 + (min/max)**2)
    24	MOVQ    BX, X0
    25	MOVQ    CX, X1
    26	ORQ     CX, BX
    27	JEQ     isZero
    28	MOVAPD  X0, X2
    29	MAXSD   X1, X0
    30	MINSD   X2, X1
    31	DIVSD   X0, X1
    32	MULSD   X1, X1
    33	ADDSD   $1.0, X1
    34	SQRTSD  X1, X1
    35	MULSD   X1, X0
    36	MOVSD   X0, ret+16(FP)
    37	RET
    38isInfOrNaN:
    39	CMPQ    AX, BX
    40	JEQ     isInf
    41	CMPQ    AX, CX
    42	JEQ     isInf
    43	MOVQ    $NaN, AX
    44	MOVQ    AX, ret+16(FP) // return NaN
    45	RET
    46isInf:
    47	MOVQ    AX, ret+16(FP) // return +Inf
    48	RET
    49isZero:
    50	MOVQ    $0, AX
    51	MOVQ    AX, ret+16(FP) // return 0
    52	RET

View as plain text