1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
3 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
4 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
5 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
6 
7 #ifdef STRICT
8 // Test that the constrained intrinsics are picking up the exception
9 // metadata from the AST instead of the global default from the command line.
10 
11 #pragma float_control(except, on)
12 #endif
13 
14 
15 #include <immintrin.h>
16 
test_mm_sqrt_ps(__m128 x)17 __m128 test_mm_sqrt_ps(__m128 x) {
18   // COMMON-LABEL: test_mm_sqrt_ps
19   // UNCONSTRAINED: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
20   // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> {{.*}}, metadata !{{.*}})
21   // CHECK-ASM: sqrtps
22   return _mm_sqrt_ps(x);
23 }
24 
test_sqrt_ss(__m128 x)25 __m128 test_sqrt_ss(__m128 x) {
26   // COMMON-LABEL: test_sqrt_ss
27   // COMMONIR: extractelement <4 x float> {{.*}}, i64 0
28   // UNCONSTRAINED: call float @llvm.sqrt.f32(float {{.*}})
29   // CONSTRAINED: call float @llvm.experimental.constrained.sqrt.f32(float {{.*}}, metadata !{{.*}})
30   // CHECK-ASM: sqrtss
31   // COMMONIR: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
32   return _mm_sqrt_ss(x);
33 }
34 
35