26 lines · cpp
1// RUN: %clangxx_nsan -O0 -g -mavx %s -o %t2// RUN: env NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s3// RUN: %clangxx_nsan -O3 -g -mavx %s -o %t4// RUN: env NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s5#include <iostream>6#include <cmath>7 8typedef float v8sf __attribute__ ((vector_size(32)));9 10v8sf simd_sqrt(v8sf a) {11 return __builtin_elementwise_sqrt(a);12 // CHECK: WARNING: NumericalStabilitySanitizer: NaN detected13}14 15int main() {16 v8sf a = {-1.0, -2.0, -3.0, 4.0, 5.0, 6.0, 7.0, 8.0};17 a = simd_sqrt(a);18 19 // This prevents DCE.20 for (size_t i = 0; i < 8; ++i) {21 std::cout << a[i] << std::endl;22 // CHECK: WARNING: NumericalStabilitySanitizer: NaN detected23 }24 return 0;25}26