| 1 |
// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -fclangir -emit-cir -o %t.cir -Wall -Werror |
| 2 |
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s |
| 3 |
// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -fclangir -emit-llvm -o %t.ll -Wall -Werror |
| 4 |
// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s |
| 5 |
|
| 6 |
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 7 |
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 8 |
|
| 9 |
#include <immintrin.h> |
| 10 |
|
| 11 |
__m128h test_mm_undefined_ph(void) { |
| 12 |
// CIR-LABEL: _mm_undefined_ph |
| 13 |
// CIR: %[[A:.*]] = cir.const #cir.zero : !cir.vector<2 x !cir.double> |
| 14 |
// CIR: %{{.*}} = cir.cast bitcast %[[A]] : !cir.vector<2 x !cir.double> -> !cir.vector<8 x !cir.f16> |
| 15 |
// CIR: cir.return %{{.*}} : !cir.vector<8 x !cir.f16> |
| 16 |
|
| 17 |
// CIR-LABEL: cir.func {{.*}}test_mm_undefined_ph |
| 18 |
// CIR: call @_mm_undefined_ph |
| 19 |
|
| 20 |
// LLVM-LABEL: @test_mm_undefined_ph |
| 21 |
// LLVM: store <8 x half> zeroinitializer, ptr %[[A:.*]], align 16 |
| 22 |
// LLVM: %{{.*}} = load <8 x half>, ptr %[[A]], align 16 |
| 23 |
// LLVM: ret <8 x half> %{{.*}} |
| 24 |
|
| 25 |
// OGCG-LABEL: test_mm_undefined_ph |
| 26 |
// OGCG: ret <8 x half> zeroinitializer |
| 27 |
return _mm_undefined_ph(); |
| 28 |
} |
| 29 |
|
| 30 |
__m256h test_mm256_undefined_ph(void) { |
| 31 |
// CIR-LABEL: _mm256_undefined_ph |
| 32 |
// CIR: %[[A:.*]] = cir.const #cir.zero : !cir.vector<4 x !cir.double> |
| 33 |
// CIR: %{{.*}} = cir.cast bitcast %[[A]] : !cir.vector<4 x !cir.double> -> !cir.vector<16 x !cir.f16> |
| 34 |
// CIR: cir.return %{{.*}} : !cir.vector<16 x !cir.f16> |
| 35 |
|
| 36 |
// CIR-LABEL: cir.func {{.*}}test_mm256_undefined_ph |
| 37 |
// CIR: call @_mm256_undefined_ph |
| 38 |
|
| 39 |
// LLVM-LABEL: @test_mm256_undefined_ph |
| 40 |
// LLVM: store <16 x half> zeroinitializer, ptr %[[A:.*]], align 32 |
| 41 |
// LLVM: %{{.*}} = load <16 x half>, ptr %[[A]], align 32 |
| 42 |
// LLVM: ret <16 x half> %{{.*}} |
| 43 |
|
| 44 |
// OGCG-LABEL: test_mm256_undefined_ph |
| 45 |
// OGCG: ret <16 x half> zeroinitializer |
| 46 |
return _mm256_undefined_ph(); |
| 47 |
} |
| 48 |
|
| 49 |
__m512h test_mm512_undefined_ph(void) { |
| 50 |
// CIR-LABEL: _mm512_undefined_ph |
| 51 |
// CIR: %[[A:.*]] = cir.const #cir.zero : !cir.vector<8 x !cir.double> |
| 52 |
// CIR: %{{.*}} = cir.cast bitcast %[[A]] : !cir.vector<8 x !cir.double> -> !cir.vector<32 x !cir.f16> |
| 53 |
// CIR: cir.return %{{.*}} : !cir.vector<32 x !cir.f16> |
| 54 |
|
| 55 |
// CIR-LABEL: cir.func {{.*}}test_mm512_undefined_ph |
| 56 |
// CIR: call @_mm512_undefined_ph |
| 57 |
|
| 58 |
// LLVM-LABEL: @test_mm512_undefined_ph |
| 59 |
// LLVM: store <32 x half> zeroinitializer, ptr %[[A:.*]], align 64 |
| 60 |
// LLVM: %{{.*}} = load <32 x half>, ptr %[[A]], align 64 |
| 61 |
// LLVM: ret <32 x half> %{{.*}} |
| 62 |
|
| 63 |
// OGCG-LABEL: test_mm512_undefined_ph |
| 64 |
// OGCG: ret <32 x half> zeroinitializer |
| 65 |
return _mm512_undefined_ph(); |
| 66 |
} |
| 67 |
|
| 68 |
_Float16 test_mm512_reduce_add_ph(__m512h __W) { |
| 69 |
// CIR-LABEL: _mm512_reduce_add_ph |
| 70 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fadd" %[[R:.*]], %[[V:.*]] : (!cir.f16, !cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 71 |
|
| 72 |
// CIR-LABEL: test_mm512_reduce_add_ph |
| 73 |
// CIR: cir.call @_mm512_reduce_add_ph(%[[VEC:.*]]) : (!cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 74 |
|
| 75 |
// LLVM-LABEL: test_mm512_reduce_add_ph |
| 76 |
// LLVM: call half @llvm.vector.reduce.fadd.v32f16(half 0xH8000, <32 x half> %{{.*}}) |
| 77 |
|
| 78 |
// OGCG-LABEL: test_mm512_reduce_add_ph |
| 79 |
// OGCG: call reassoc {{.*}}half @llvm.vector.reduce.fadd.v32f16(half 0xH8000, <32 x half> %{{.*}}) |
| 80 |
return _mm512_reduce_add_ph(__W); |
| 81 |
} |
| 82 |
|
| 83 |
_Float16 test_mm512_reduce_mul_ph(__m512h __W) { |
| 84 |
// CIR-LABEL: _mm512_reduce_mul_ph |
| 85 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmul" %[[R:.*]], %[[V:.*]] : (!cir.f16, !cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 86 |
|
| 87 |
// CIR-LABEL: test_mm512_reduce_mul_ph |
| 88 |
// CIR: cir.call @_mm512_reduce_mul_ph(%[[VEC:.*]]) : (!cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 89 |
|
| 90 |
// LLVM-LABEL: test_mm512_reduce_mul_ph |
| 91 |
// LLVM: call half @llvm.vector.reduce.fmul.v32f16(half 0xH3C00, <32 x half> %{{.*}}) |
| 92 |
|
| 93 |
// OGCG-LABEL: test_mm512_reduce_mul_ph |
| 94 |
// OGCG: call reassoc {{.*}}half @llvm.vector.reduce.fmul.v32f16(half 0xH3C00, <32 x half> %{{.*}}) |
| 95 |
return _mm512_reduce_mul_ph(__W); |
| 96 |
} |
| 97 |
|
| 98 |
_Float16 test_mm512_reduce_max_ph(__m512h __W) { |
| 99 |
// CIR-LABEL: _mm512_reduce_max_ph |
| 100 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmax" %[[V:.*]] (!cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 101 |
|
| 102 |
// CIR-LABEL: test_mm512_reduce_max_ph |
| 103 |
// CIR: cir.call @_mm512_reduce_max_ph(%[[VEC:.*]]) : (!cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 104 |
|
| 105 |
// LLVM-LABEL: test_mm512_reduce_max_ph |
| 106 |
// LLVM: call half @llvm.vector.reduce.fmax.v32f16(<32 x half> %{{.*}}) |
| 107 |
|
| 108 |
// OGCG-LABEL: test_mm512_reduce_max_ph |
| 109 |
// OGCG: call nnan {{.*}}half @llvm.vector.reduce.fmax.v32f16(<32 x half> %{{.*}}) |
| 110 |
return _mm512_reduce_max_ph(__W); |
| 111 |
} |
| 112 |
|
| 113 |
_Float16 test_mm512_reduce_min_ph(__m512h __W) { |
| 114 |
// CIR-LABEL: _mm512_reduce_min_ph |
| 115 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmin" %[[V:.*]] (!cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 116 |
|
| 117 |
// CIR-LABEL: test_mm512_reduce_min_ph |
| 118 |
// CIR: cir.call @_mm512_reduce_min_ph(%[[VEC:.*]]) : (!cir.vector<32 x !cir.f16>) -> !cir.f16 |
| 119 |
|
| 120 |
// LLVM-LABEL: test_mm512_reduce_min_ph |
| 121 |
// LLVM: call half @llvm.vector.reduce.fmin.v32f16(<32 x half> %{{.*}}) |
| 122 |
|
| 123 |
// OGCG-LABEL: test_mm512_reduce_min_ph |
| 124 |
// OGCG: call nnan {{.*}}half @llvm.vector.reduce.fmin.v32f16(<32 x half> %{{.*}}) |
| 125 |
return _mm512_reduce_min_ph(__W); |
| 126 |
} |