Skip to content

Commit fcb8342

Browse files
authored
[LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (#78962)
This PR adds definitions and 'frecipe' feature for FP approximation intrinsics/builtins. In additions, this adds and complements relative testcases.
1 parent 86f0547 commit fcb8342

26 files changed

+548
-0
lines changed

clang/include/clang/Basic/BuiltinsLoongArchBase.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ TARGET_BUILTIN(__builtin_loongarch_iocsrwr_d, "vUWiUi", "nc", "64bit")
5151

5252
TARGET_BUILTIN(__builtin_loongarch_lddir_d, "WiWiIUWi", "nc", "64bit")
5353
TARGET_BUILTIN(__builtin_loongarch_ldpte_d, "vWiIUWi", "nc", "64bit")
54+
55+
TARGET_BUILTIN(__builtin_loongarch_frecipe_s, "ff", "nc", "f,frecipe")
56+
TARGET_BUILTIN(__builtin_loongarch_frecipe_d, "dd", "nc", "d,frecipe")
57+
TARGET_BUILTIN(__builtin_loongarch_frsqrte_s, "ff", "nc", "f,frecipe")
58+
TARGET_BUILTIN(__builtin_loongarch_frsqrte_d, "dd", "nc", "d,frecipe")

clang/include/clang/Basic/BuiltinsLoongArchLASX.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,15 @@ TARGET_BUILTIN(__builtin_lasx_xvfsqrt_d, "V4dV4d", "nc", "lasx")
657657
TARGET_BUILTIN(__builtin_lasx_xvfrecip_s, "V8fV8f", "nc", "lasx")
658658
TARGET_BUILTIN(__builtin_lasx_xvfrecip_d, "V4dV4d", "nc", "lasx")
659659

660+
TARGET_BUILTIN(__builtin_lasx_xvfrecipe_s, "V8fV8f", "nc", "lasx,frecipe")
661+
TARGET_BUILTIN(__builtin_lasx_xvfrecipe_d, "V4dV4d", "nc", "lasx,frecipe")
662+
660663
TARGET_BUILTIN(__builtin_lasx_xvfrsqrt_s, "V8fV8f", "nc", "lasx")
661664
TARGET_BUILTIN(__builtin_lasx_xvfrsqrt_d, "V4dV4d", "nc", "lasx")
662665

666+
TARGET_BUILTIN(__builtin_lasx_xvfrsqrte_s, "V8fV8f", "nc", "lasx,frecipe")
667+
TARGET_BUILTIN(__builtin_lasx_xvfrsqrte_d, "V4dV4d", "nc", "lasx,frecipe")
668+
663669
TARGET_BUILTIN(__builtin_lasx_xvfcvtl_s_h, "V8fV16s", "nc", "lasx")
664670
TARGET_BUILTIN(__builtin_lasx_xvfcvth_s_h, "V8fV16s", "nc", "lasx")
665671
TARGET_BUILTIN(__builtin_lasx_xvfcvtl_d_s, "V4dV8f", "nc", "lasx")

clang/include/clang/Basic/BuiltinsLoongArchLSX.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,15 @@ TARGET_BUILTIN(__builtin_lsx_vfsqrt_d, "V2dV2d", "nc", "lsx")
641641
TARGET_BUILTIN(__builtin_lsx_vfrecip_s, "V4fV4f", "nc", "lsx")
642642
TARGET_BUILTIN(__builtin_lsx_vfrecip_d, "V2dV2d", "nc", "lsx")
643643

644+
TARGET_BUILTIN(__builtin_lsx_vfrecipe_s, "V4fV4f", "nc", "lsx,frecipe")
645+
TARGET_BUILTIN(__builtin_lsx_vfrecipe_d, "V2dV2d", "nc", "lsx,frecipe")
646+
644647
TARGET_BUILTIN(__builtin_lsx_vfrsqrt_s, "V4fV4f", "nc", "lsx")
645648
TARGET_BUILTIN(__builtin_lsx_vfrsqrt_d, "V2dV2d", "nc", "lsx")
646649

650+
TARGET_BUILTIN(__builtin_lsx_vfrsqrte_s, "V4fV4f", "nc", "lsx,frecipe")
651+
TARGET_BUILTIN(__builtin_lsx_vfrsqrte_d, "V2dV2d", "nc", "lsx,frecipe")
652+
647653
TARGET_BUILTIN(__builtin_lsx_vfcvtl_s_h, "V4fV8s", "nc", "lsx")
648654
TARGET_BUILTIN(__builtin_lsx_vfcvtl_d_s, "V2dV4f", "nc", "lsx")
649655

clang/lib/Headers/larchintrin.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ extern __inline void
228228
((void)__builtin_loongarch_ldpte_d((long int)(_1), (_2)))
229229
#endif
230230

231+
#define __frecipe_s(/*float*/ _1) \
232+
(float)__builtin_loongarch_frecipe_s((float)_1)
233+
234+
#define __frecipe_d(/*double*/ _1) \
235+
(double)__builtin_loongarch_frecipe_d((double)_1)
236+
237+
#define __frsqrte_s(/*float*/ _1) \
238+
(float)__builtin_loongarch_frsqrte_s((float)_1)
239+
240+
#define __frsqrte_d(/*double*/ _1) \
241+
(double)__builtin_loongarch_frsqrte_d((double)_1)
242+
231243
#ifdef __cplusplus
232244
}
233245
#endif

clang/lib/Headers/lasxintrin.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,18 @@ extern __inline
17261726
return (__m256d)__builtin_lasx_xvfrecip_d((v4f64)_1);
17271727
}
17281728

1729+
extern __inline
1730+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256
1731+
__lasx_xvfrecipe_s(__m256 _1) {
1732+
return (__m256)__builtin_lasx_xvfrecipe_s((v8f32)_1);
1733+
}
1734+
1735+
extern __inline
1736+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d
1737+
__lasx_xvfrecipe_d(__m256d _1) {
1738+
return (__m256d)__builtin_lasx_xvfrecipe_d((v4f64)_1);
1739+
}
1740+
17291741
extern __inline
17301742
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256
17311743
__lasx_xvfrint_s(__m256 _1) {
@@ -1750,6 +1762,18 @@ extern __inline
17501762
return (__m256d)__builtin_lasx_xvfrsqrt_d((v4f64)_1);
17511763
}
17521764

1765+
extern __inline
1766+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256
1767+
__lasx_xvfrsqrte_s(__m256 _1) {
1768+
return (__m256)__builtin_lasx_xvfrsqrte_s((v8f32)_1);
1769+
}
1770+
1771+
extern __inline
1772+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d
1773+
__lasx_xvfrsqrte_d(__m256d _1) {
1774+
return (__m256d)__builtin_lasx_xvfrsqrte_d((v4f64)_1);
1775+
}
1776+
17531777
extern __inline
17541778
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256
17551779
__lasx_xvflogb_s(__m256 _1) {

clang/lib/Headers/lsxintrin.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,18 @@ extern __inline
17761776
return (__m128d)__builtin_lsx_vfrecip_d((v2f64)_1);
17771777
}
17781778

1779+
extern __inline
1780+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128
1781+
__lsx_vfrecipe_s(__m128 _1) {
1782+
return (__m128)__builtin_lsx_vfrecipe_s((v4f32)_1);
1783+
}
1784+
1785+
extern __inline
1786+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d
1787+
__lsx_vfrecipe_d(__m128d _1) {
1788+
return (__m128d)__builtin_lsx_vfrecipe_d((v2f64)_1);
1789+
}
1790+
17791791
extern __inline
17801792
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128
17811793
__lsx_vfrint_s(__m128 _1) {
@@ -1800,6 +1812,18 @@ extern __inline
18001812
return (__m128d)__builtin_lsx_vfrsqrt_d((v2f64)_1);
18011813
}
18021814

1815+
extern __inline
1816+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128
1817+
__lsx_vfrsqrte_s(__m128 _1) {
1818+
return (__m128)__builtin_lsx_vfrsqrte_s((v4f32)_1);
1819+
}
1820+
1821+
extern __inline
1822+
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d
1823+
__lsx_vfrsqrte_d(__m128d _1) {
1824+
return (__m128d)__builtin_lsx_vfrsqrte_d((v2f64)_1);
1825+
}
1826+
18031827
extern __inline
18041828
__attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128
18051829
__lsx_vflogb_s(__m128 _1) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
2+
// RUN: %clang_cc1 -triple loongarch32 -target-feature +d -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
3+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +d -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
4+
5+
#include <larchintrin.h>
6+
7+
// CHECK-LABEL: @frecipe_d
8+
// CHECK-NEXT: entry:
9+
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frecipe.d(double [[A:%.*]])
10+
// CHECK-NEXT: ret double [[TMP0]]
11+
//
12+
double frecipe_d (double _1)
13+
{
14+
return __builtin_loongarch_frecipe_d (_1);
15+
}
16+
17+
// CHECK-LABEL: @frsqrte_d
18+
// CHECK-NEXT: entry:
19+
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frsqrte.d(double [[A:%.*]])
20+
// CHECK-NEXT: ret double [[TMP0]]
21+
//
22+
double frsqrte_d (double _1)
23+
{
24+
return __builtin_loongarch_frsqrte_d (_1);
25+
}
26+
27+
// CHECK-LABEL: @frecipe_d_alia
28+
// CHECK-NEXT: entry:
29+
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frecipe.d(double [[A:%.*]])
30+
// CHECK-NEXT: ret double [[TMP0]]
31+
//
32+
double frecipe_d_alia (double _1)
33+
{
34+
return __frecipe_d (_1);
35+
}
36+
37+
// CHECK-LABEL: @frsqrte_d_alia
38+
// CHECK-NEXT: entry:
39+
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frsqrte.d(double [[A:%.*]])
40+
// CHECK-NEXT: ret double [[TMP0]]
41+
//
42+
double frsqrte_d_alia (double _1)
43+
{
44+
return __frsqrte_d (_1);
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
2+
// RUN: %clang_cc1 -triple loongarch32 -target-feature +f -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
3+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
4+
5+
#include <larchintrin.h>
6+
7+
// CHECK-LABEL: @frecipe_s
8+
// CHECK-NEXT: entry:
9+
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frecipe.s(float [[A:%.*]])
10+
// CHECK-NEXT: ret float [[TMP0]]
11+
//
12+
float frecipe_s (float _1)
13+
{
14+
return __builtin_loongarch_frecipe_s (_1);
15+
}
16+
17+
// CHECK-LABEL: @frsqrte_s
18+
// CHECK-NEXT: entry:
19+
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frsqrte.s(float [[A:%.*]])
20+
// CHECK-NEXT: ret float [[TMP0]]
21+
//
22+
float frsqrte_s (float _1)
23+
{
24+
return __builtin_loongarch_frsqrte_s (_1);
25+
}
26+
27+
// CHECK-LABEL: @frecipe_s_alia
28+
// CHECK-NEXT: entry:
29+
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frecipe.s(float [[A:%.*]])
30+
// CHECK-NEXT: ret float [[TMP0]]
31+
//
32+
float frecipe_s_alia (float _1)
33+
{
34+
return __frecipe_s (_1);
35+
}
36+
37+
// CHECK-LABEL: @frsqrte_s_alia
38+
// CHECK-NEXT: entry:
39+
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frsqrte.s(float [[A:%.*]])
40+
// CHECK-NEXT: ret float [[TMP0]]
41+
//
42+
float frsqrte_s_alia (float _1)
43+
{
44+
return __frsqrte_s (_1);
45+
}

clang/test/CodeGen/LoongArch/intrinsic-la64-error.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
// RUN: %clang_cc1 -triple loongarch64 -emit-llvm -S -verify %s -o /dev/null
2+
// RUN: not %clang_cc1 -triple loongarch64 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \
3+
// RUN: | FileCheck %s
24

35
#include <larchintrin.h>
46

7+
#ifdef FEATURE_CHECK
8+
void test_feature(unsigned long *v_ul, int *v_i, float a, double b) {
9+
// CHECK: error: '__builtin_loongarch_cacop_w' needs target feature 32bit
10+
__builtin_loongarch_cacop_w(1, v_ul[0], 1024);
11+
// CHECK: error: '__builtin_loongarch_movfcsr2gr' needs target feature f
12+
v_i[0] = __builtin_loongarch_movfcsr2gr(1);
13+
// CHECK: error: '__builtin_loongarch_movgr2fcsr' needs target feature f
14+
__builtin_loongarch_movgr2fcsr(1, v_i[1]);
15+
// CHECK: error: '__builtin_loongarch_frecipe_s' needs target feature f,frecipe
16+
float f1 = __builtin_loongarch_frecipe_s(a);
17+
// CHECK: error: '__builtin_loongarch_frsqrte_s' needs target feature f,frecipe
18+
float f2 = __builtin_loongarch_frsqrte_s(a);
19+
// CHECK: error: '__builtin_loongarch_frecipe_d' needs target feature d,frecipe
20+
double d1 = __builtin_loongarch_frecipe_d(b);
21+
// CHECK: error: '__builtin_loongarch_frsqrte_d' needs target feature d,frecipe
22+
double d2 = __builtin_loongarch_frsqrte_d(b);
23+
}
24+
#endif
25+
526
void csrrd_d(int a) {
627
__builtin_loongarch_csrrd_d(16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}
728
__builtin_loongarch_csrrd_d(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lasx -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
3+
4+
#include <lasxintrin.h>
5+
6+
// CHECK-LABEL: @xvfrecipe_s(
7+
// CHECK-NEXT: entry:
8+
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
9+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrecipe.s(<8 x float> [[_1]])
10+
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
11+
// CHECK-NEXT: ret void
12+
//
13+
v8f32 xvfrecipe_s(v8f32 _1) { return __lasx_xvfrecipe_s(_1); }
14+
// CHECK-LABEL: @xvfrecipe_d(
15+
// CHECK-NEXT: entry:
16+
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
17+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrecipe.d(<4 x double> [[_1]])
18+
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
19+
// CHECK-NEXT: ret void
20+
//
21+
v4f64 xvfrecipe_d(v4f64 _1) { return __lasx_xvfrecipe_d(_1); }
22+
// CHECK-LABEL: @xvfrsqrte_s(
23+
// CHECK-NEXT: entry:
24+
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
25+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrsqrte.s(<8 x float> [[_1]])
26+
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
27+
// CHECK-NEXT: ret void
28+
//
29+
v8f32 xvfrsqrte_s(v8f32 _1) { return __lasx_xvfrsqrte_s(_1); }
30+
// CHECK-LABEL: @xvfrsqrte_d(
31+
// CHECK-NEXT: entry:
32+
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
33+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrsqrte.d(<4 x double> [[_1]])
34+
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
35+
// CHECK-NEXT: ret void
36+
//
37+
v4f64 xvfrsqrte_d(v4f64 _1) { return __lasx_xvfrsqrte_d(_1); }
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lasx -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
3+
4+
typedef float v8f32 __attribute__((vector_size(32), aligned(32)));
5+
typedef double v4f64 __attribute__((vector_size(32), aligned(32)));
6+
7+
// CHECK-LABEL: @xvfrecipe_s
8+
// CHECK-NEXT: entry:
9+
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
10+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrecipe.s(<8 x float> [[_1]])
11+
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
12+
// CHECK-NEXT: ret void
13+
//
14+
v8f32 xvfrecipe_s(v8f32 _1) { return __builtin_lasx_xvfrecipe_s(_1); }
15+
// CHECK-LABEL: @xvfrecipe_d
16+
// CHECK-NEXT: entry:
17+
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
18+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrecipe.d(<4 x double> [[_1]])
19+
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
20+
// CHECK-NEXT: ret void
21+
//
22+
v4f64 xvfrecipe_d(v4f64 _1) { return __builtin_lasx_xvfrecipe_d(_1); }
23+
// CHECK-LABEL: @xvfrsqrte_s
24+
// CHECK-NEXT: entry:
25+
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
26+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrsqrte.s(<8 x float> [[_1]])
27+
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
28+
// CHECK-NEXT: ret void
29+
//
30+
v8f32 xvfrsqrte_s(v8f32 _1) { return __builtin_lasx_xvfrsqrte_s(_1); }
31+
// CHECK-LABEL: @xvfrsqrte_d
32+
// CHECK-NEXT: entry:
33+
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]]
34+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrsqrte.d(<4 x double> [[_1]])
35+
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]]
36+
// CHECK-NEXT: ret void
37+
//
38+
v4f64 xvfrsqrte_d(v4f64 _1) { return __builtin_lasx_xvfrsqrte_d(_1); }
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lsx -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s
3+
4+
#include <lsxintrin.h>
5+
6+
// CHECK-LABEL: @vfrecipe_s(
7+
// CHECK-NEXT: entry:
8+
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <4 x float>
9+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.loongarch.lsx.vfrecipe.s(<4 x float> [[TMP0]])
10+
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <4 x float> [[TMP1]] to i128
11+
// CHECK-NEXT: ret i128 [[TMP2]]
12+
//
13+
v4f32 vfrecipe_s(v4f32 _1) { return __lsx_vfrecipe_s(_1); }
14+
// CHECK-LABEL: @vfrecipe_d(
15+
// CHECK-NEXT: entry:
16+
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <2 x double>
17+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.loongarch.lsx.vfrecipe.d(<2 x double> [[TMP0]])
18+
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x double> [[TMP1]] to i128
19+
// CHECK-NEXT: ret i128 [[TMP2]]
20+
//
21+
v2f64 vfrecipe_d(v2f64 _1) { return __lsx_vfrecipe_d(_1); }
22+
// CHECK-LABEL: @vfrsqrte_s(
23+
// CHECK-NEXT: entry:
24+
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <4 x float>
25+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.loongarch.lsx.vfrsqrte.s(<4 x float> [[TMP0]])
26+
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <4 x float> [[TMP1]] to i128
27+
// CHECK-NEXT: ret i128 [[TMP2]]
28+
//
29+
v4f32 vfrsqrte_s(v4f32 _1) { return __lsx_vfrsqrte_s(_1); }
30+
// CHECK-LABEL: @vfrsqrte_d(
31+
// CHECK-NEXT: entry:
32+
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <2 x double>
33+
// CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.loongarch.lsx.vfrsqrte.d(<2 x double> [[TMP0]])
34+
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x double> [[TMP1]] to i128
35+
// CHECK-NEXT: ret i128 [[TMP2]]
36+
//
37+
v2f64 vfrsqrte_d(v2f64 _1) { return __lsx_vfrsqrte_d(_1); }

0 commit comments

Comments
 (0)