(root)/
glibc-2.38/
sysdeps/
x86_64/
fpu/
multiarch/
s_fma.c
       1  /* FMA version of fma.
       2     Copyright (C) 2009-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library; if not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #define NO_MATH_REDIRECT
      20  #include <config.h>
      21  #define dfmal __hide_dfmal
      22  #define f32xfmaf64 __hide_f32xfmaf64
      23  #include <math.h>
      24  #undef dfmal
      25  #undef f32xfmaf64
      26  #include <init-arch.h>
      27  #include <libm-alias-double.h>
      28  #include <math-narrow-alias.h>
      29  
      30  extern double __fma_sse2 (double x, double y, double z) attribute_hidden;
      31  
      32  
      33  static double
      34  __fma_fma3 (double x, double y, double z)
      35  {
      36    asm ("vfmadd213sd %3, %2, %0" : "=x" (x) : "0" (x), "x" (y), "xm" (z));
      37    return x;
      38  }
      39  
      40  
      41  static double
      42  __fma_fma4 (double x, double y, double z)
      43  {
      44    asm ("vfmaddsd %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
      45    return x;
      46  }
      47  
      48  
      49  libm_ifunc (__fma, CPU_FEATURE_USABLE (FMA)
      50  	    ? __fma_fma3 : (CPU_FEATURE_USABLE (FMA4)
      51  			    ? __fma_fma4 : __fma_sse2));
      52  libm_alias_double (__fma, fma)
      53  libm_alias_double_narrow (__fma, fma)
      54  
      55  #define __fma __fma_sse2
      56  
      57  #include <sysdeps/ieee754/dbl-64/s_fma.c>