[libc-commits] [libc] [libc][NFC] Tighten up guard conditions for sqrt and polyeval (PR #93791)
via libc-commits
libc-commits at lists.llvm.org
Thu May 30 02:08:14 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Guillaume Chatelet (gchatelet)
<details>
<summary>Changes</summary>
Found while investigating #<!-- -->93709
---
Full diff: https://github.com/llvm/llvm-project/pull/93791.diff
3 Files Affected:
- (modified) libc/src/__support/FPUtil/sqrt.h (+2-1)
- (modified) libc/src/__support/FPUtil/x86_64/PolyEval.h (+4-2)
- (modified) libc/src/__support/FPUtil/x86_64/sqrt.h (+3-2)
``````````diff
diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h
index 3ba1bdf687a3e..eb86ddfa89d8e 100644
--- a/libc/src/__support/FPUtil/sqrt.h
+++ b/libc/src/__support/FPUtil/sqrt.h
@@ -10,8 +10,9 @@
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_SQRT_H
#include "src/__support/macros/properties/architectures.h"
+#include "src/__support/macros/properties/cpu_features.h"
-#if defined(LIBC_TARGET_ARCH_IS_X86_64)
+#if defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE2)
#include "x86_64/sqrt.h"
#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
#include "aarch64/sqrt.h"
diff --git a/libc/src/__support/FPUtil/x86_64/PolyEval.h b/libc/src/__support/FPUtil/x86_64/PolyEval.h
index 69fd776320799..713fa029021e2 100644
--- a/libc/src/__support/FPUtil/x86_64/PolyEval.h
+++ b/libc/src/__support/FPUtil/x86_64/PolyEval.h
@@ -11,9 +11,11 @@
#include "src/__support/common.h"
#include "src/__support/macros/properties/architectures.h"
+#include "src/__support/macros/properties/cpu_features.h"
-#if !defined(LIBC_TARGET_ARCH_IS_X86_64)
-#error "Invalid include"
+#if !(defined(LIBC_TARGET_ARCH_IS_X86_64) && \
+ defined(LIBC_TARGET_CPU_HAS_SSE2) && defined(LIBC_TARGET_CPU_HAS_FMA))
+#error "Missing FMA and SS2 support"
#endif
#include <immintrin.h>
diff --git a/libc/src/__support/FPUtil/x86_64/sqrt.h b/libc/src/__support/FPUtil/x86_64/sqrt.h
index 93ba8c0b33fdc..bfcc5e98834d6 100644
--- a/libc/src/__support/FPUtil/x86_64/sqrt.h
+++ b/libc/src/__support/FPUtil/x86_64/sqrt.h
@@ -11,9 +11,10 @@
#include "src/__support/common.h"
#include "src/__support/macros/properties/architectures.h"
+#include "src/__support/macros/properties/cpu_features.h"
-#if !defined(LIBC_TARGET_ARCH_IS_X86)
-#error "Invalid include"
+#if !(defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE2))
+#error "sqrtss / sqrtsd need SSE2"
#endif
#include "src/__support/FPUtil/generic/sqrt.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/93791
More information about the libc-commits
mailing list