소스 검색

math: move trivial x86-family sqrt functions to C with inline asm

Alexander Monakov 5 년 전
부모
커밋
41b290ba39
8개의 변경된 파일28개의 추가작업 그리고 18개의 파일을 삭제
  1. 7 0
      src/math/i386/sqrtl.c
  2. 0 5
      src/math/i386/sqrtl.s
  3. 7 0
      src/math/x86_64/sqrt.c
  4. 0 4
      src/math/x86_64/sqrt.s
  5. 7 0
      src/math/x86_64/sqrtf.c
  6. 0 4
      src/math/x86_64/sqrtf.s
  7. 7 0
      src/math/x86_64/sqrtl.c
  8. 0 5
      src/math/x86_64/sqrtl.s

+ 7 - 0
src/math/i386/sqrtl.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double sqrtl(long double x)
+{
+	__asm__ ("fsqrt" : "+t"(x));
+	return x;
+}

+ 0 - 5
src/math/i386/sqrtl.s

@@ -1,5 +0,0 @@
-.global sqrtl
-.type sqrtl,@function
-sqrtl:	fldt 4(%esp)
-	fsqrt
-	ret

+ 7 - 0
src/math/x86_64/sqrt.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+double sqrt(double x)
+{
+	__asm__ ("sqrtsd %1, %0" : "=x"(x) : "x"(x));
+	return x;
+}

+ 0 - 4
src/math/x86_64/sqrt.s

@@ -1,4 +0,0 @@
-.global sqrt
-.type sqrt,@function
-sqrt:	sqrtsd %xmm0, %xmm0
-	ret

+ 7 - 0
src/math/x86_64/sqrtf.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+float sqrtf(float x)
+{
+	__asm__ ("sqrtss %1, %0" : "=x"(x) : "x"(x));
+	return x;
+}

+ 0 - 4
src/math/x86_64/sqrtf.s

@@ -1,4 +0,0 @@
-.global sqrtf
-.type sqrtf,@function
-sqrtf:  sqrtss %xmm0, %xmm0
-	ret

+ 7 - 0
src/math/x86_64/sqrtl.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double sqrtl(long double x)
+{
+	__asm__ ("fsqrt" : "+t"(x));
+	return x;
+}

+ 0 - 5
src/math/x86_64/sqrtl.s

@@ -1,5 +0,0 @@
-.global sqrtl
-.type sqrtl,@function
-sqrtl:	fldt 8(%rsp)
-	fsqrt
-	ret