Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CFE][X86] Enable complex _Float16 support
Support complex _Float16 on X86 in C/C++ following the latest X86 psABI. (https://gitlab.com/x86-psABIs) Reviewed By: LuoYuanke Differential Revision: https://reviews.llvm.org/D105331
- Loading branch information
1 parent
59dfde7
commit 5aeca3b
Showing
5 changed files
with
152 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -target-feature +avx512fp16 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK | ||
|
||
// Return value should be passed in <2 x half> so the backend will use xmm0 | ||
_Complex _Float16 f16(_Complex _Float16 A, _Complex _Float16 B) { | ||
// CHECK-LABEL: define{{.*}}<2 x half> @f16({ half, half }* byval({ half, half }) align 4 %{{.*}}, { half, half }* byval({ half, half }) align 4 %{{.*}}) | ||
return A + B; | ||
} |
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,133 @@ | ||
// RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple x86_64-unknown-unknown -target-feature +avx512fp16 -o - | FileCheck %s --check-prefix=X86 | ||
|
||
_Float16 _Complex add_half_rr(_Float16 a, _Float16 b) { | ||
// X86-LABEL: @add_half_rr( | ||
// X86: fadd | ||
// X86-NOT: fadd | ||
// X86: ret | ||
return a + b; | ||
} | ||
_Float16 _Complex add_half_cr(_Float16 _Complex a, _Float16 b) { | ||
// X86-LABEL: @add_half_cr( | ||
// X86: fadd | ||
// X86-NOT: fadd | ||
// X86: ret | ||
return a + b; | ||
} | ||
_Float16 _Complex add_half_rc(_Float16 a, _Float16 _Complex b) { | ||
// X86-LABEL: @add_half_rc( | ||
// X86: fadd | ||
// X86-NOT: fadd | ||
// X86: ret | ||
return a + b; | ||
} | ||
_Float16 _Complex add_half_cc(_Float16 _Complex a, _Float16 _Complex b) { | ||
// X86-LABEL: @add_half_cc( | ||
// X86: fadd | ||
// X86: fadd | ||
// X86-NOT: fadd | ||
// X86: ret | ||
return a + b; | ||
} | ||
|
||
_Float16 _Complex sub_half_rr(_Float16 a, _Float16 b) { | ||
// X86-LABEL: @sub_half_rr( | ||
// X86: fsub | ||
// X86-NOT: fsub | ||
// X86: ret | ||
return a - b; | ||
} | ||
_Float16 _Complex sub_half_cr(_Float16 _Complex a, _Float16 b) { | ||
// X86-LABEL: @sub_half_cr( | ||
// X86: fsub | ||
// X86-NOT: fsub | ||
// X86: ret | ||
return a - b; | ||
} | ||
_Float16 _Complex sub_half_rc(_Float16 a, _Float16 _Complex b) { | ||
// X86-LABEL: @sub_half_rc( | ||
// X86: fsub | ||
// X86: fneg | ||
// X86-NOT: fsub | ||
// X86: ret | ||
return a - b; | ||
} | ||
_Float16 _Complex sub_half_cc(_Float16 _Complex a, _Float16 _Complex b) { | ||
// X86-LABEL: @sub_half_cc( | ||
// X86: fsub | ||
// X86: fsub | ||
// X86-NOT: fsub | ||
// X86: ret | ||
return a - b; | ||
} | ||
|
||
_Float16 _Complex mul_half_rr(_Float16 a, _Float16 b) { | ||
// X86-LABEL: @mul_half_rr( | ||
// X86: fmul | ||
// X86-NOT: fmul | ||
// X86: ret | ||
return a * b; | ||
} | ||
_Float16 _Complex mul_half_cr(_Float16 _Complex a, _Float16 b) { | ||
// X86-LABEL: @mul_half_cr( | ||
// X86: fmul | ||
// X86: fmul | ||
// X86-NOT: fmul | ||
// X86: ret | ||
return a * b; | ||
} | ||
_Float16 _Complex mul_half_rc(_Float16 a, _Float16 _Complex b) { | ||
// X86-LABEL: @mul_half_rc( | ||
// X86: fmul | ||
// X86: fmul | ||
// X86-NOT: fmul | ||
// X86: ret | ||
return a * b; | ||
} | ||
_Float16 _Complex mul_half_cc(_Float16 _Complex a, _Float16 _Complex b) { | ||
// X86-LABEL: @mul_half_cc( | ||
// X86: %[[AC:[^ ]+]] = fmul | ||
// X86: %[[BD:[^ ]+]] = fmul | ||
// X86: %[[AD:[^ ]+]] = fmul | ||
// X86: %[[BC:[^ ]+]] = fmul | ||
// X86: %[[RR:[^ ]+]] = fsub half %[[AC]], %[[BD]] | ||
// X86: %[[RI:[^ ]+]] = fadd half | ||
// X86-DAG: %[[AD]] | ||
// X86-DAG: , | ||
// X86-DAG: %[[BC]] | ||
// X86: fcmp uno half %[[RR]] | ||
// X86: fcmp uno half %[[RI]] | ||
// X86: call {{.*}} @__mulhc3( | ||
// X86: ret | ||
return a * b; | ||
} | ||
|
||
_Float16 _Complex div_half_rr(_Float16 a, _Float16 b) { | ||
// X86-LABEL: @div_half_rr( | ||
// X86: fdiv | ||
// X86-NOT: fdiv | ||
// X86: ret | ||
return a / b; | ||
} | ||
_Float16 _Complex div_half_cr(_Float16 _Complex a, _Float16 b) { | ||
// X86-LABEL: @div_half_cr( | ||
// X86: fdiv | ||
// X86: fdiv | ||
// X86-NOT: fdiv | ||
// X86: ret | ||
return a / b; | ||
} | ||
_Float16 _Complex div_half_rc(_Float16 a, _Float16 _Complex b) { | ||
// X86-LABEL: @div_half_rc( | ||
// X86-NOT: fdiv | ||
// X86: call {{.*}} @__divhc3( | ||
// X86: ret | ||
return a / b; | ||
} | ||
_Float16 _Complex div_half_cc(_Float16 _Complex a, _Float16 _Complex b) { | ||
// X86-LABEL: @div_half_cc( | ||
// X86-NOT: fdiv | ||
// X86: call {{.*}} @__divhc3( | ||
// X86: ret | ||
return a / b; | ||
} |
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