llvm-project/compiler-rt/test/nsan/vec_sqrt_ext.cpp
Harini0924 52ae891036
[compiler-rt][test] Add env command to fix command not found errors in compiler-rt with lit internal shell (#105917)
There are several files in the compiler-rt subproject that have command
not found errors. This patch uses the `env` command to properly set the
environment variables correctly when using the lit internal shell.
fixes: #102395 
[This change is relevant [RFC] Enabling the lit internal shell by
Default](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
2024-08-25 21:36:34 -07:00

26 lines
748 B
C++

// RUN: %clangxx_nsan -O0 -g -mavx %s -o %t
// RUN: env 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: env NSAN_OPTIONS=check_nan=true,halt_on_error=0 %run %t 2>&1 | FileCheck %s
#include <iostream>
#include <cmath>
typedef float v8sf __attribute__ ((vector_size(32)));
v8sf simd_sqrt(v8sf a) {
return __builtin_elementwise_sqrt(a);
// CHECK: WARNING: NumericalStabilitySanitizer: NaN detected
}
int main() {
v8sf a = {-1.0, -2.0, -3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
a = simd_sqrt(a);
// This prevents DCE.
for (size_t i = 0; i < 8; ++i) {
std::cout << a[i] << std::endl;
// CHECK: WARNING: NumericalStabilitySanitizer: NaN detected
}
return 0;
}