[compiler-rt] [compiler-rt][nsan] Add support for nan detection (PR #101531)
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 13:11:49 PDT 2024
================
@@ -0,0 +1,35 @@
+// RUN: %clangxx_nsan -O0 -g -mavx %s -o %t
+// RUN: NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_nsan -O3 -g -mavx %s -o %t
+// RUN: NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s
+
+#include <cmath>
+#include <immintrin.h>
+#include <iostream>
+
+void simd_sqrt(const float *input, float *output, size_t size) {
+ size_t i = 0;
+ for (; i + 7 < size; i += 8) {
+ __m256 vec = _mm256_loadu_ps(&input[i]);
+ __m256 result = _mm256_sqrt_ps(vec);
+ _mm256_storeu_ps(&output[i], result);
+ // when simd is used, the warning is not triggered
----------------
alexander-shaposhnikov wrote:
it looks like something is broken.
we'd like to detect cases like this, the report below triggered by std::sqrt below is not relevant, need to figure out/understand what's broken for simd.
https://github.com/llvm/llvm-project/pull/101531
More information about the llvm-commits
mailing list