-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoongArch] Add definitions and feature 'frecipe' for FP approximatio…
…n intrinsics/builtins (#78962) This PR adds definitions and 'frecipe' feature for FP approximation intrinsics/builtins. In additions, this adds and complements relative testcases.
- Loading branch information
Showing
26 changed files
with
548 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 | ||
// RUN: %clang_cc1 -triple loongarch32 -target-feature +d -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
// RUN: %clang_cc1 -triple loongarch64 -target-feature +d -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
|
||
#include <larchintrin.h> | ||
|
||
// CHECK-LABEL: @frecipe_d | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frecipe.d(double [[A:%.*]]) | ||
// CHECK-NEXT: ret double [[TMP0]] | ||
// | ||
double frecipe_d (double _1) | ||
{ | ||
return __builtin_loongarch_frecipe_d (_1); | ||
} | ||
|
||
// CHECK-LABEL: @frsqrte_d | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frsqrte.d(double [[A:%.*]]) | ||
// CHECK-NEXT: ret double [[TMP0]] | ||
// | ||
double frsqrte_d (double _1) | ||
{ | ||
return __builtin_loongarch_frsqrte_d (_1); | ||
} | ||
|
||
// CHECK-LABEL: @frecipe_d_alia | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frecipe.d(double [[A:%.*]]) | ||
// CHECK-NEXT: ret double [[TMP0]] | ||
// | ||
double frecipe_d_alia (double _1) | ||
{ | ||
return __frecipe_d (_1); | ||
} | ||
|
||
// CHECK-LABEL: @frsqrte_d_alia | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call double @llvm.loongarch.frsqrte.d(double [[A:%.*]]) | ||
// CHECK-NEXT: ret double [[TMP0]] | ||
// | ||
double frsqrte_d_alia (double _1) | ||
{ | ||
return __frsqrte_d (_1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 | ||
// RUN: %clang_cc1 -triple loongarch32 -target-feature +f -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
|
||
#include <larchintrin.h> | ||
|
||
// CHECK-LABEL: @frecipe_s | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frecipe.s(float [[A:%.*]]) | ||
// CHECK-NEXT: ret float [[TMP0]] | ||
// | ||
float frecipe_s (float _1) | ||
{ | ||
return __builtin_loongarch_frecipe_s (_1); | ||
} | ||
|
||
// CHECK-LABEL: @frsqrte_s | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frsqrte.s(float [[A:%.*]]) | ||
// CHECK-NEXT: ret float [[TMP0]] | ||
// | ||
float frsqrte_s (float _1) | ||
{ | ||
return __builtin_loongarch_frsqrte_s (_1); | ||
} | ||
|
||
// CHECK-LABEL: @frecipe_s_alia | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frecipe.s(float [[A:%.*]]) | ||
// CHECK-NEXT: ret float [[TMP0]] | ||
// | ||
float frecipe_s_alia (float _1) | ||
{ | ||
return __frecipe_s (_1); | ||
} | ||
|
||
// CHECK-LABEL: @frsqrte_s_alia | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.loongarch.frsqrte.s(float [[A:%.*]]) | ||
// CHECK-NEXT: ret float [[TMP0]] | ||
// | ||
float frsqrte_s_alia (float _1) | ||
{ | ||
return __frsqrte_s (_1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
clang/test/CodeGen/LoongArch/lasx/builtin-approximate-alias.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lasx -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
|
||
#include <lasxintrin.h> | ||
|
||
// CHECK-LABEL: @xvfrecipe_s( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrecipe.s(<8 x float> [[_1]]) | ||
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v8f32 xvfrecipe_s(v8f32 _1) { return __lasx_xvfrecipe_s(_1); } | ||
// CHECK-LABEL: @xvfrecipe_d( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrecipe.d(<4 x double> [[_1]]) | ||
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v4f64 xvfrecipe_d(v4f64 _1) { return __lasx_xvfrecipe_d(_1); } | ||
// CHECK-LABEL: @xvfrsqrte_s( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrsqrte.s(<8 x float> [[_1]]) | ||
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v8f32 xvfrsqrte_s(v8f32 _1) { return __lasx_xvfrsqrte_s(_1); } | ||
// CHECK-LABEL: @xvfrsqrte_d( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrsqrte.d(<4 x double> [[_1]]) | ||
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v4f64 xvfrsqrte_d(v4f64 _1) { return __lasx_xvfrsqrte_d(_1); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lasx -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
|
||
typedef float v8f32 __attribute__((vector_size(32), aligned(32))); | ||
typedef double v4f64 __attribute__((vector_size(32), aligned(32))); | ||
|
||
// CHECK-LABEL: @xvfrecipe_s | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrecipe.s(<8 x float> [[_1]]) | ||
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v8f32 xvfrecipe_s(v8f32 _1) { return __builtin_lasx_xvfrecipe_s(_1); } | ||
// CHECK-LABEL: @xvfrecipe_d | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrecipe.d(<4 x double> [[_1]]) | ||
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v4f64 xvfrecipe_d(v4f64 _1) { return __builtin_lasx_xvfrecipe_d(_1); } | ||
// CHECK-LABEL: @xvfrsqrte_s | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <8 x float>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x float> @llvm.loongarch.lasx.xvfrsqrte.s(<8 x float> [[_1]]) | ||
// CHECK-NEXT: store <8 x float> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v8f32 xvfrsqrte_s(v8f32 _1) { return __builtin_lasx_xvfrsqrte_s(_1); } | ||
// CHECK-LABEL: @xvfrsqrte_d | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[_1:%.*]] = load <4 x double>, ptr [[TMP0:%.*]], align 32, !tbaa [[TBAA2:![0-9]+]] | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x double> @llvm.loongarch.lasx.xvfrsqrte.d(<4 x double> [[_1]]) | ||
// CHECK-NEXT: store <4 x double> [[TMP1]], ptr [[AGG_RESULT:%.*]], align 32, !tbaa [[TBAA2]] | ||
// CHECK-NEXT: ret void | ||
// | ||
v4f64 xvfrsqrte_d(v4f64 _1) { return __builtin_lasx_xvfrsqrte_d(_1); } |
37 changes: 37 additions & 0 deletions
37
clang/test/CodeGen/LoongArch/lsx/builtin-approximate-alias.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple loongarch64 -target-feature +lsx -target-feature +frecipe -O2 -emit-llvm %s -o - | FileCheck %s | ||
|
||
#include <lsxintrin.h> | ||
|
||
// CHECK-LABEL: @vfrecipe_s( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <4 x float> | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.loongarch.lsx.vfrecipe.s(<4 x float> [[TMP0]]) | ||
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <4 x float> [[TMP1]] to i128 | ||
// CHECK-NEXT: ret i128 [[TMP2]] | ||
// | ||
v4f32 vfrecipe_s(v4f32 _1) { return __lsx_vfrecipe_s(_1); } | ||
// CHECK-LABEL: @vfrecipe_d( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <2 x double> | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.loongarch.lsx.vfrecipe.d(<2 x double> [[TMP0]]) | ||
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x double> [[TMP1]] to i128 | ||
// CHECK-NEXT: ret i128 [[TMP2]] | ||
// | ||
v2f64 vfrecipe_d(v2f64 _1) { return __lsx_vfrecipe_d(_1); } | ||
// CHECK-LABEL: @vfrsqrte_s( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <4 x float> | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.loongarch.lsx.vfrsqrte.s(<4 x float> [[TMP0]]) | ||
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <4 x float> [[TMP1]] to i128 | ||
// CHECK-NEXT: ret i128 [[TMP2]] | ||
// | ||
v4f32 vfrsqrte_s(v4f32 _1) { return __lsx_vfrsqrte_s(_1); } | ||
// CHECK-LABEL: @vfrsqrte_d( | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = bitcast i128 [[_1_COERCE:%.*]] to <2 x double> | ||
// CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.loongarch.lsx.vfrsqrte.d(<2 x double> [[TMP0]]) | ||
// CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x double> [[TMP1]] to i128 | ||
// CHECK-NEXT: ret i128 [[TMP2]] | ||
// | ||
v2f64 vfrsqrte_d(v2f64 _1) { return __lsx_vfrsqrte_d(_1); } |
Oops, something went wrong.