| 1 |
// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512vl -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 +avx512vl -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 +avx512vl -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 +avx512vl -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG |
| 8 |
#include <immintrin.h> |
| 9 |
|
| 10 |
_Float16 test_mm256_reduce_add_ph(__m256h __W) { |
| 11 |
// CIR-LABEL: _mm256_reduce_add_ph |
| 12 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fadd" %[[R:.*]], %[[V:.*]] : (!cir.f16, !cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 13 |
|
| 14 |
// CIR-LABEL: test_mm256_reduce_add_ph |
| 15 |
// CIR: cir.call @_mm256_reduce_add_ph(%[[VEC:.*]]) : (!cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 16 |
|
| 17 |
// LLVM-LABEL: test_mm256_reduce_add_ph |
| 18 |
// LLVM: call half @llvm.vector.reduce.fadd.v16f16(half 0xH8000, <16 x half> %{{.*}}) |
| 19 |
|
| 20 |
// OGCG-LABEL: test_mm256_reduce_add_ph |
| 21 |
// OGCG: call reassoc {{.*}}@llvm.vector.reduce.fadd.v16f16(half 0xH8000, <16 x half> %{{.*}}) |
| 22 |
return _mm256_reduce_add_ph(__W); |
| 23 |
} |
| 24 |
|
| 25 |
_Float16 test_mm256_reduce_mul_ph(__m256h __W) { |
| 26 |
// CIR-LABEL: _mm256_reduce_mul_ph |
| 27 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmul" %[[R:.*]], %[[V:.*]] : (!cir.f16, !cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 28 |
|
| 29 |
// CIR-LABEL: test_mm256_reduce_mul_ph |
| 30 |
// CIR: cir.call @_mm256_reduce_mul_ph(%[[VEC:.*]]) : (!cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 31 |
|
| 32 |
// LLVM-LABEL: test_mm256_reduce_mul_ph |
| 33 |
// LLVM: call half @llvm.vector.reduce.fmul.v16f16(half 0xH3C00, <16 x half> %{{.*}}) |
| 34 |
|
| 35 |
// OGCG-LABEL: test_mm256_reduce_mul_ph |
| 36 |
// OGCG: call reassoc {{.*}}@llvm.vector.reduce.fmul.v16f16(half 0xH3C00, <16 x half> %{{.*}}) |
| 37 |
return _mm256_reduce_mul_ph(__W); |
| 38 |
} |
| 39 |
|
| 40 |
_Float16 test_mm256_reduce_max_ph(__m256h __W) { |
| 41 |
// CIR-LABEL: _mm256_reduce_max_ph |
| 42 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmax" %[[V:.*]] (!cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 43 |
|
| 44 |
// CIR-LABEL: test_mm256_reduce_max_ph |
| 45 |
// CIR: cir.call @_mm256_reduce_max_ph(%[[VEC:.*]]) : (!cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 46 |
|
| 47 |
// LLVM-LABEL: test_mm256_reduce_max_ph |
| 48 |
// LLVM: call half @llvm.vector.reduce.fmax.v16f16(<16 x half> %{{.*}}) |
| 49 |
|
| 50 |
// OGCG-LABEL: test_mm256_reduce_max_ph |
| 51 |
// OGCG: call nnan {{.*}}@llvm.vector.reduce.fmax.v16f16(<16 x half> %{{.*}}) |
| 52 |
return _mm256_reduce_max_ph(__W); |
| 53 |
} |
| 54 |
|
| 55 |
_Float16 test_mm256_reduce_min_ph(__m256h __W) { |
| 56 |
// CIR-LABEL: _mm256_reduce_min_ph |
| 57 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmin" %[[V:.*]] : (!cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 58 |
|
| 59 |
// CIR-LABEL: test_mm256_reduce_min_ph |
| 60 |
// CIR: cir.call @_mm256_reduce_min_ph(%[[VEC:.*]]) : (!cir.vector<16 x !cir.f16>) -> !cir.f16 |
| 61 |
|
| 62 |
// LLVM-LABEL: test_mm256_reduce_min_ph |
| 63 |
// LLVM: call half @llvm.vector.reduce.fmin.v16f16(<16 x half> %{{.*}}) |
| 64 |
|
| 65 |
// OGCG-LABEL: test_mm256_reduce_min_ph |
| 66 |
// OGCG: call nnan {{.*}}@llvm.vector.reduce.fmin.v16f16(<16 x half> %{{.*}}) |
| 67 |
return _mm256_reduce_min_ph(__W); |
| 68 |
} |
| 69 |
|
| 70 |
_Float16 test_mm_reduce_add_ph(__m128h __W) { |
| 71 |
// CIR-LABEL: _mm_reduce_add_ph |
| 72 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fadd" %[[R:.*]], %[[V:.*]] : (!cir.f16, !cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 73 |
|
| 74 |
// CIR-LABEL: test_mm_reduce_add_ph |
| 75 |
// CIR: cir.call @_mm_reduce_add_ph(%[[VEC:.*]]) : (!cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 76 |
|
| 77 |
// LLVM-LABEL: test_mm_reduce_add_ph |
| 78 |
// LLVM: call half @llvm.vector.reduce.fadd.v8f16(half 0xH8000, <8 x half> %{{.*}}) |
| 79 |
|
| 80 |
// OGCG-LABEL: test_mm_reduce_add_ph |
| 81 |
// OGCG: call reassoc {{.*}}@llvm.vector.reduce.fadd.v8f16(half 0xH8000, <8 x half> %{{.*}}) |
| 82 |
return _mm_reduce_add_ph(__W); |
| 83 |
} |
| 84 |
|
| 85 |
_Float16 test_mm_reduce_mul_ph(__m128h __W) { |
| 86 |
// CIR-LABEL: _mm_reduce_mul_ph |
| 87 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmul" %[[R:.*]], %[[V:.*]] : (!cir.f16, !cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 88 |
|
| 89 |
// CIR-LABEL: test_mm_reduce_mul_ph |
| 90 |
// CIR: cir.call @_mm_reduce_mul_ph(%[[VEC:.*]]) : (!cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 91 |
|
| 92 |
// LLVM-LABEL: test_mm_reduce_mul_ph |
| 93 |
// LLVM: call half @llvm.vector.reduce.fmul.v8f16(half 0xH3C00, <8 x half> %{{.*}}) |
| 94 |
|
| 95 |
// OGCG-LABEL: test_mm_reduce_mul_ph |
| 96 |
// OGCG: call reassoc {{.*}}@llvm.vector.reduce.fmul.v8f16(half 0xH3C00, <8 x half> %{{.*}}) |
| 97 |
return _mm_reduce_mul_ph(__W); |
| 98 |
} |
| 99 |
|
| 100 |
_Float16 test_mm_reduce_max_ph(__m128h __W) { |
| 101 |
// CIR-LABEL: _mm_reduce_max_ph |
| 102 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmax" %[[V:.*]] (!cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 103 |
|
| 104 |
// CIR-LABEL: test_mm_reduce_max_ph |
| 105 |
// CIR: cir.call @_mm_reduce_max_ph(%[[VEC:.*]]) : (!cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 106 |
|
| 107 |
// LLVM-LABEL: test_mm_reduce_max_ph |
| 108 |
// LLVM: call half @llvm.vector.reduce.fmax.v8f16(<8 x half> %{{.*}}) |
| 109 |
|
| 110 |
// OGCG-LABEL: test_mm_reduce_max_ph |
| 111 |
// OGCG: call nnan {{.*}}@llvm.vector.reduce.fmax.v8f16(<8 x half> %{{.*}}) |
| 112 |
return _mm_reduce_max_ph(__W); |
| 113 |
} |
| 114 |
|
| 115 |
_Float16 test_mm_reduce_min_ph(__m128h __W) { |
| 116 |
// CIR-LABEL: _mm_reduce_min_ph |
| 117 |
// CIR: cir.call_llvm_intrinsic "vector.reduce.fmin" %[[V:.*]] : (!cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 118 |
|
| 119 |
// CIR-LABEL: test_mm_reduce_min_ph |
| 120 |
// CIR: cir.call @_mm_reduce_min_ph(%[[VEC:.*]]) : (!cir.vector<8 x !cir.f16>) -> !cir.f16 |
| 121 |
|
| 122 |
// LLVM-LABEL: test_mm_reduce_min_ph |
| 123 |
// LLVM: call half @llvm.vector.reduce.fmin.v8f16(<8 x half> %{{.*}}) |
| 124 |
|
| 125 |
// OGCG-LABEL: test_mm_reduce_min_ph |
| 126 |
// OGCG: call nnan {{.*}}@llvm.vector.reduce.fmin.v8f16(<8 x half> %{{.*}}) |
| 127 |
return _mm_reduce_min_ph(__W); |
| 128 |
} |
| 129 |
|