|
| 1 | +// REQUIRES: x86-registered-target |
| 2 | +// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON |
| 3 | +// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON |
| 4 | +// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -S -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON |
| 5 | +// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=maytrap -DSTRICT=1 -S -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON |
| 6 | +// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON |
| 7 | +// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON |
| 8 | +// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -S -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON |
| 9 | +// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512vl -target-feature +avx512fp16 -ffp-exception-behavior=maytrap -DSTRICT=1 -S -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON |
| 10 | + |
| 11 | +#ifdef STRICT |
| 12 | +// Test that the constrained intrinsics are picking up the exception |
| 13 | +// metadata from the AST instead of the global default from the command line. |
| 14 | + |
| 15 | +#pragma float_control(except, on) |
| 16 | +#endif |
| 17 | + |
| 18 | + |
| 19 | +#include <immintrin.h> |
| 20 | + |
| 21 | +__m128h test_mm_sqrt_sh(__m128h x, __m128h y) { |
| 22 | + // COMMON-LABEL: test_mm_sqrt_sh |
| 23 | + // UNCONSTRAINED: call {{.*}}half @llvm.sqrt.f16(half {{.*}}) |
| 24 | + // CONSTRAINED: call {{.*}}half @llvm.experimental.constrained.sqrt.f16(half {{.*}}, metadata !{{.*}}) |
| 25 | + // CHECK-ASM: vsqrtsh %xmm{{.*}}, |
| 26 | + return _mm_sqrt_sh(x, y); |
| 27 | +} |
| 28 | + |
| 29 | +__m128h test_mm_mask_sqrt_sh(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B){ |
| 30 | + // COMMON-LABEL: test_mm_mask_sqrt_sh |
| 31 | + // COMMONIR: extractelement <8 x half> %{{.*}}, i64 0 |
| 32 | + // UNCONSTRAINED: call {{.*}}half @llvm.sqrt.f16(half %{{.*}}) |
| 33 | + // CONSTRAINED: call {{.*}}half @llvm.experimental.constrained.sqrt.f16(half %{{.*}}, metadata !{{.*}}) |
| 34 | + // CHECK-ASM: vsqrtsh %xmm{{.*}}, |
| 35 | + // COMMONIR-NEXT: extractelement <8 x half> %{{.*}}, i64 0 |
| 36 | + // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1> |
| 37 | + // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0 |
| 38 | + // COMMONIR-NEXT: select i1 {{.*}}, half {{.*}}, half {{.*}} |
| 39 | + // COMMONIR-NEXT: insertelement <8 x half> %{{.*}}, half {{.*}}, i64 0 |
| 40 | + return _mm_mask_sqrt_sh(__W,__U,__A,__B); |
| 41 | +} |
| 42 | + |
| 43 | +__m128h test_mm_maskz_sqrt_sh(__mmask8 __U, __m128h __A, __m128h __B){ |
| 44 | + // COMMON-LABEL: test_mm_maskz_sqrt_sh |
| 45 | + // COMMONIR: extractelement <2 x half> %{{.*}}, i64 0 |
| 46 | + // UNCONSTRAINED: call {{.*}}half @llvm.sqrt.f16(half %{{.*}}) |
| 47 | + // CONSTRAINED: call {{.*}}half @llvm.experimental.constrained.sqrt.f16(half %{{.*}}, metadata !{{.*}}) |
| 48 | + // CHECK-ASM: vsqrtsh %xmm{{.*}}, |
| 49 | + // COMMONIR-NEXT: extractelement <2 x half> %{{.*}}, i64 0 |
| 50 | + // COMMONIR-NEXT: bitcast i8 %{{.*}} to <8 x i1> |
| 51 | + // COMMONIR-NEXT: extractelement <8 x i1> %{{.*}}, i64 0 |
| 52 | + // COMMONIR-NEXT: select i1 {{.*}}, half {{.*}}, half {{.*}} |
| 53 | + // COMMONIR-NEXT: insertelement <2 x half> %{{.*}}, half {{.*}}, i64 0 |
| 54 | + return _mm_maskz_sqrt_sh(__U,__A,__B); |
| 55 | +} |
| 56 | + |
| 57 | +__m512h test_mm512_sqrt_ph(__m512h x) { |
| 58 | + // COMMON-LABEL: test_mm512_sqrt_ph |
| 59 | + // UNCONSTRAINED: call {{.*}}<32 x half> @llvm.sqrt.v32f16(<32 x half> {{.*}}) |
| 60 | + // CONSTRAINED: call {{.*}}<32 x half> @llvm.experimental.constrained.sqrt.v32f16(<32 x half> {{.*}}, metadata !{{.*}}) |
| 61 | + // CHECK-ASM: vsqrtph %zmm{{.*}}, |
| 62 | + return _mm512_sqrt_ph(x); |
| 63 | +} |
| 64 | + |
| 65 | +__m512h test_mm512_mask_sqrt_ph (__m512h __W, __mmask32 __U, __m512h __A) |
| 66 | +{ |
| 67 | + // COMMON-LABEL: test_mm512_mask_sqrt_ph |
| 68 | + // UNCONSTRAINED: call <32 x half> @llvm.sqrt.v32f16(<32 x half> %{{.*}}) |
| 69 | + // CONSTRAINED: call <32 x half> @llvm.experimental.constrained.sqrt.v32f16(<32 x half> %{{.*}}, metadata !{{.*}}) |
| 70 | + // CHECK-ASM: vsqrtph %zmm{{.*}}, |
| 71 | + // COMMONIR: bitcast i32 %{{.*}} to <32 x i1> |
| 72 | + // COMMONIR: select <32 x i1> %{{.*}}, <32 x half> %{{.*}}, <32 x half> %{{.*}} |
| 73 | + return _mm512_mask_sqrt_ph (__W,__U,__A); |
| 74 | +} |
| 75 | + |
| 76 | +__m512h test_mm512_maskz_sqrt_ph (__mmask32 __U, __m512h __A) |
| 77 | +{ |
| 78 | + // COMMON-LABEL: test_mm512_maskz_sqrt_ph |
| 79 | + // UNCONSTRAINED: call <32 x half> @llvm.sqrt.v32f16(<32 x half> %{{.*}}) |
| 80 | + // CONSTRAINED: call <32 x half> @llvm.experimental.constrained.sqrt.v32f16(<32 x half> %{{.*}}, metadata !{{.*}}) |
| 81 | + // CHECK-ASM: vsqrtph %zmm{{.*}}, |
| 82 | + // COMMONIR: bitcast i32 %{{.*}} to <32 x i1> |
| 83 | + // COMMONIR: select <32 x i1> %{{.*}}, <32 x half> %{{.*}}, <32 x half> {{.*}} |
| 84 | + return _mm512_maskz_sqrt_ph (__U,__A); |
| 85 | +} |
0 commit comments