github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/math/dim_amd64.s (about)

     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  #define NegInf 0xFFF0000000000000
    10  
    11  // func ·archMax(x, y float64) float64
    12  TEXT ·archMax(SB),NOSPLIT,$0
    13  	// +Inf special cases
    14  	MOVQ    $PosInf, AX
    15  	MOVQ    x+0(FP), R8
    16  	CMPQ    AX, R8
    17  	JEQ     isPosInf
    18  	MOVQ    y+8(FP), R9
    19  	CMPQ    AX, R9
    20  	JEQ     isPosInf
    21  	// NaN special cases
    22  	MOVQ    $~(1<<63), DX // bit mask
    23  	MOVQ    $PosInf, AX
    24  	MOVQ    R8, BX
    25  	ANDQ    DX, BX // x = |x|
    26  	CMPQ    AX, BX
    27  	JLT     isMaxNaN
    28  	MOVQ    R9, CX
    29  	ANDQ    DX, CX // y = |y|
    30  	CMPQ    AX, CX
    31  	JLT     isMaxNaN
    32  	// ±0 special cases
    33  	ORQ     CX, BX
    34  	JEQ     isMaxZero
    35  
    36  	MOVQ    R8, X0
    37  	MOVQ    R9, X1
    38  	MAXSD   X1, X0
    39  	MOVSD   X0, ret+16(FP)
    40  	RET
    41  isMaxNaN: // return NaN
    42  	MOVQ	$NaN, AX
    43  isPosInf: // return +Inf
    44  	MOVQ    AX, ret+16(FP)
    45  	RET
    46  isMaxZero:
    47  	MOVQ    $(1<<63), AX // -0.0
    48  	CMPQ    AX, R8
    49  	JEQ     +3(PC)
    50  	MOVQ    R8, ret+16(FP) // return 0
    51  	RET
    52  	MOVQ    R9, ret+16(FP) // return other 0
    53  	RET
    54  
    55  // func archMin(x, y float64) float64
    56  TEXT ·archMin(SB),NOSPLIT,$0
    57  	// -Inf special cases
    58  	MOVQ    $NegInf, AX
    59  	MOVQ    x+0(FP), R8
    60  	CMPQ    AX, R8
    61  	JEQ     isNegInf
    62  	MOVQ    y+8(FP), R9
    63  	CMPQ    AX, R9
    64  	JEQ     isNegInf
    65  	// NaN special cases
    66  	MOVQ    $~(1<<63), DX
    67  	MOVQ    $PosInf, AX
    68  	MOVQ    R8, BX
    69  	ANDQ    DX, BX // x = |x|
    70  	CMPQ    AX, BX
    71  	JLT     isMinNaN
    72  	MOVQ    R9, CX
    73  	ANDQ    DX, CX // y = |y|
    74  	CMPQ    AX, CX
    75  	JLT     isMinNaN
    76  	// ±0 special cases
    77  	ORQ     CX, BX
    78  	JEQ     isMinZero
    79  
    80  	MOVQ    R8, X0
    81  	MOVQ    R9, X1
    82  	MINSD   X1, X0
    83  	MOVSD X0, ret+16(FP)
    84  	RET
    85  isMinNaN: // return NaN
    86  	MOVQ	$NaN, AX
    87  isNegInf: // return -Inf
    88  	MOVQ    AX, ret+16(FP)
    89  	RET
    90  isMinZero:
    91  	MOVQ    $(1<<63), AX // -0.0
    92  	CMPQ    AX, R8
    93  	JEQ     +3(PC)
    94  	MOVQ    R9, ret+16(FP) // return other 0
    95  	RET
    96  	MOVQ    R8, ret+16(FP) // return -0
    97  	RET
    98