commit 6623c02d70c3732dbea59c6d79c69501baf9627b Author: Zahira Ammarguellat Date: Wed Nov 17 11:53:36 2021 -0500 The _Float16 type is supported on x86 systems with SSE2 enabled. Operations are emulated by software emulation and “float” instructions. This patch is allowing the support of _Float16 type without the use of -max512fp16 flag. The final goal being, perform _Float16 emulation for all arithmetic expressions. Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/docs/LanguageExtensions.rst =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/docs/LanguageExtensions.rst +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/docs/LanguageExtensions.rst @@ -673,7 +673,7 @@ targets pending ABI standardization: * 64-bit ARM (AArch64) * AMDGPU * SPIR -* X86 (Available with feature SSE2 and up enabled) +* X86 (Only available under feature AVX512-FP16) ``_Float16`` will be supported on more targets as they define ABIs for it. Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/docs/ReleaseNotes.rst =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/docs/ReleaseNotes.rst +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/docs/ReleaseNotes.rst @@ -187,7 +187,6 @@ X86 Support in Clang -------------------- - Support for ``AVX512-FP16`` instructions has been added. -- Support for ``_Float16`` type has been added. Arm and AArch64 Support in Clang -------------------------------- Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/lib/Basic/Targets/X86.cpp =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/lib/Basic/Targets/X86.cpp +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/lib/Basic/Targets/X86.cpp @@ -239,9 +239,9 @@ bool X86TargetInfo::handleTargetFeatures HasAVX512ER = true; } else if (Feature == "+avx512fp16") { HasAVX512FP16 = true; + HasFloat16 = true; } else if (Feature == "+avx512pf") { HasAVX512PF = true; - HasLegalHalfType = true; } else if (Feature == "+avx512dq") { HasAVX512DQ = true; } else if (Feature == "+avx512bitalg") { @@ -369,8 +369,6 @@ bool X86TargetInfo::handleTargetFeatures .Default(NoXOP); XOPLevel = std::max(XOPLevel, XLevel); } - // Turn on _float16 for x86 (feature sse2) - HasFloat16 = SSELevel >= SSE2; // LLVM doesn't have a separate switch for fpmath, so only accept it if it // matches the selected sse level. Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/Float16-arithmetic.c =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/test/CodeGen/X86/Float16-arithmetic.c +++ /dev/null @@ -1,73 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm \ -// RUN: < %s | FileCheck %s --check-prefixes=CHECK - -_Float16 add1(_Float16 a, _Float16 b) { - // CHECK-LABEL: define{{.*}} half @add1 - // CHECK: alloca half - // CHECK: alloca half - // CHECK: store half {{.*}}, half* - // CHECK: store half {{.*}}, half* - // CHECK: load half, half* - // CHECK: load half, half* {{.*}} - // CHECK: fadd half {{.*}}, {{.*}} - // CHECK: ret half - return a + b; -} - -_Float16 add2(_Float16 a, _Float16 b, _Float16 c) { - // CHECK-LABEL: define{{.*}} half @add2 - // CHECK: alloca half - // CHECK: alloca half - // CHECK: alloca half - // CHECK: store half {{.*}}, half* - // CHECK: store half {{.*}}, half* - // CHECK: store half {{.*}}, half* - // CHECK: load half, half* {{.*}} - // CHECK: load half, half* {{.*}} - // CHECK: fadd half {{.*}}, {{.*}} - // CHECK: load half, half* {{.*}} - // CHECK: fadd half {{.*}}, {{.*}} - // CHECK: ret half - return a + b + c; -} - -_Float16 sub(_Float16 a, _Float16 b) { - // CHECK-LABEL: define{{.*}} half @sub - // CHECK: alloca half - // CHECK: alloca half - // CHECK: store half {{.*}}, half* - // CHECK: store half {{.*}}, half* - // CHECK: load half, half* - // CHECK: load half, half* {{.*}} - // CHECK: fsub half {{.*}}, {{.*}} - // CHECK: ret half - return a - b; -} - -_Float16 div(_Float16 a, _Float16 b) { - // CHECK-LABEL: define{{.*}} half @div - // CHECK: alloca half - // CHECK: alloca half - // CHECK: store half {{.*}}, half* - // CHECK: store half {{.*}}, half* - // CHECK: load half, half* {{.*}} - // CHECK: load half, half* {{.*}} - // CHECK: fdiv half {{.*}}, {{.*}} - // CHECK: ret half - return a / b; -} - -_Float16 mul(_Float16 a, _Float16 b) { - // CHECK-LABEL: define{{.*}} half @mul - // CHECK: alloca half - // CHECK: alloca half - // CHECK: store half {{.*}}, half* - // CHECK: store half {{.*}}, half* - // CHECK: load half, half* {{.*}} - // CHECK: load half, half* {{.*}} - // CHECK: fmul half {{.*}}, {{.*}} - // CHECK: ret half - return a * b; -} - - Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/fp16-abi.c =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/test/CodeGen/X86/fp16-abi.c +++ /dev/null @@ -1,242 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +avx512fp16 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-C -// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm < %s | FileCheck %s --check-prefixes=CHECK,CHECK-C -// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +avx512fp16 -x c++ -std=c++11 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CPP -// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -x c++ -std=c++11 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CPP - -struct half1 { - _Float16 a; -}; - -struct half1 h1(_Float16 a) { - // CHECK: define{{.*}}half @ - struct half1 x; - x.a = a; - return x; -} - -struct half2 { - _Float16 a; - _Float16 b; -}; - -struct half2 h2(_Float16 a, _Float16 b) { - // CHECK: define{{.*}}<2 x half> @ - struct half2 x; - x.a = a; - x.b = b; - return x; -} - -struct half3 { - _Float16 a; - _Float16 b; - _Float16 c; -}; - -struct half3 h3(_Float16 a, _Float16 b, _Float16 c) { - // CHECK: define{{.*}}<4 x half> @ - struct half3 x; - x.a = a; - x.b = b; - x.c = c; - return x; -} - -struct half4 { - _Float16 a; - _Float16 b; - _Float16 c; - _Float16 d; -}; - -struct half4 h4(_Float16 a, _Float16 b, _Float16 c, _Float16 d) { - // CHECK: define{{.*}}<4 x half> @ - struct half4 x; - x.a = a; - x.b = b; - x.c = c; - x.d = d; - return x; -} - -struct floathalf { - float a; - _Float16 b; -}; - -struct floathalf fh(float a, _Float16 b) { - // CHECK: define{{.*}}<4 x half> @ - struct floathalf x; - x.a = a; - x.b = b; - return x; -} - -struct floathalf2 { - float a; - _Float16 b; - _Float16 c; -}; - -struct floathalf2 fh2(float a, _Float16 b, _Float16 c) { - // CHECK: define{{.*}}<4 x half> @ - struct floathalf2 x; - x.a = a; - x.b = b; - x.c = c; - return x; -} - -struct halffloat { - _Float16 a; - float b; -}; - -struct halffloat hf(_Float16 a, float b) { - // CHECK: define{{.*}}<4 x half> @ - struct halffloat x; - x.a = a; - x.b = b; - return x; -} - -struct half2float { - _Float16 a; - _Float16 b; - float c; -}; - -struct half2float h2f(_Float16 a, _Float16 b, float c) { - // CHECK: define{{.*}}<4 x half> @ - struct half2float x; - x.a = a; - x.b = b; - x.c = c; - return x; -} - -struct floathalf3 { - float a; - _Float16 b; - _Float16 c; - _Float16 d; -}; - -struct floathalf3 fh3(float a, _Float16 b, _Float16 c, _Float16 d) { - // CHECK: define{{.*}}{ <4 x half>, half } @ - struct floathalf3 x; - x.a = a; - x.b = b; - x.c = c; - x.d = d; - return x; -} - -struct half5 { - _Float16 a; - _Float16 b; - _Float16 c; - _Float16 d; - _Float16 e; -}; - -struct half5 h5(_Float16 a, _Float16 b, _Float16 c, _Float16 d, _Float16 e) { - // CHECK: define{{.*}}{ <4 x half>, half } @ - struct half5 x; - x.a = a; - x.b = b; - x.c = c; - x.d = d; - x.e = e; - return x; -} - -struct float2 { - struct {} s; - float a; - float b; -}; - -float pr51813(struct float2 s) { - // CHECK-C: define{{.*}} @pr51813(<2 x float> - // CHECK-CPP: define{{.*}} @_Z7pr518136float2(double {{.*}}, float - return s.a; -} - -struct float3 { - float a; - struct {} s; - float b; -}; - -float pr51813_2(struct float3 s) { - // CHECK-C: define{{.*}} @pr51813_2(<2 x float> - // CHECK-CPP: define{{.*}} @_Z9pr51813_26float3(double {{.*}}, float - return s.a; -} - -struct shalf2 { - struct {} s; - _Float16 a; - _Float16 b; -}; - -_Float16 sf2(struct shalf2 s) { - // CHECK-C: define{{.*}} @sf2(<2 x half> - // CHECK-CPP: define{{.*}} @_Z3sf26shalf2(double {{.*}} - return s.a; -}; - -struct halfs2 { - _Float16 a; - struct {} s1; - _Float16 b; - struct {} s2; -}; - -_Float16 fs2(struct shalf2 s) { - // CHECK-C: define{{.*}} @fs2(<2 x half> - // CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}} - return s.a; -}; - -struct fsd { - float a; - struct {}; - double b; -}; - -struct fsd pr52011() { - // CHECK: define{{.*}} { float, double } @ -} - -struct hsd { - _Float16 a; - struct {}; - double b; -}; - -struct hsd pr52011_2() { - // CHECK: define{{.*}} { half, double } @ -} - -struct hsf { - _Float16 a; - struct {}; - float b; -}; - -struct hsf pr52011_3() { - // CHECK: define{{.*}} <4 x half> @ -} - -struct fds { - float a; - double b; - struct {}; -}; - -struct fds pr52011_4() { - // CHECK-C: define{{.*}} { float, double } @pr52011_4 - // CHECK-CPP: define{{.*}} void @_Z9pr52011_4v({{.*}} sret -} Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/avx512fp16-abi.c =================================================================== --- /dev/null +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/avx512fp16-abi.c @@ -0,0 +1,240 @@ +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +avx512fp16 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-C +// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -target-feature +avx512fp16 -x c++ -std=c++11 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CPP + +struct half1 { + _Float16 a; +}; + +struct half1 h1(_Float16 a) { + // CHECK: define{{.*}}half @ + struct half1 x; + x.a = a; + return x; +} + +struct half2 { + _Float16 a; + _Float16 b; +}; + +struct half2 h2(_Float16 a, _Float16 b) { + // CHECK: define{{.*}}<2 x half> @ + struct half2 x; + x.a = a; + x.b = b; + return x; +} + +struct half3 { + _Float16 a; + _Float16 b; + _Float16 c; +}; + +struct half3 h3(_Float16 a, _Float16 b, _Float16 c) { + // CHECK: define{{.*}}<4 x half> @ + struct half3 x; + x.a = a; + x.b = b; + x.c = c; + return x; +} + +struct half4 { + _Float16 a; + _Float16 b; + _Float16 c; + _Float16 d; +}; + +struct half4 h4(_Float16 a, _Float16 b, _Float16 c, _Float16 d) { + // CHECK: define{{.*}}<4 x half> @ + struct half4 x; + x.a = a; + x.b = b; + x.c = c; + x.d = d; + return x; +} + +struct floathalf { + float a; + _Float16 b; +}; + +struct floathalf fh(float a, _Float16 b) { + // CHECK: define{{.*}}<4 x half> @ + struct floathalf x; + x.a = a; + x.b = b; + return x; +} + +struct floathalf2 { + float a; + _Float16 b; + _Float16 c; +}; + +struct floathalf2 fh2(float a, _Float16 b, _Float16 c) { + // CHECK: define{{.*}}<4 x half> @ + struct floathalf2 x; + x.a = a; + x.b = b; + x.c = c; + return x; +} + +struct halffloat { + _Float16 a; + float b; +}; + +struct halffloat hf(_Float16 a, float b) { + // CHECK: define{{.*}}<4 x half> @ + struct halffloat x; + x.a = a; + x.b = b; + return x; +} + +struct half2float { + _Float16 a; + _Float16 b; + float c; +}; + +struct half2float h2f(_Float16 a, _Float16 b, float c) { + // CHECK: define{{.*}}<4 x half> @ + struct half2float x; + x.a = a; + x.b = b; + x.c = c; + return x; +} + +struct floathalf3 { + float a; + _Float16 b; + _Float16 c; + _Float16 d; +}; + +struct floathalf3 fh3(float a, _Float16 b, _Float16 c, _Float16 d) { + // CHECK: define{{.*}}{ <4 x half>, half } @ + struct floathalf3 x; + x.a = a; + x.b = b; + x.c = c; + x.d = d; + return x; +} + +struct half5 { + _Float16 a; + _Float16 b; + _Float16 c; + _Float16 d; + _Float16 e; +}; + +struct half5 h5(_Float16 a, _Float16 b, _Float16 c, _Float16 d, _Float16 e) { + // CHECK: define{{.*}}{ <4 x half>, half } @ + struct half5 x; + x.a = a; + x.b = b; + x.c = c; + x.d = d; + x.e = e; + return x; +} + +struct float2 { + struct {} s; + float a; + float b; +}; + +float pr51813(struct float2 s) { + // CHECK-C: define{{.*}} @pr51813(<2 x float> + // CHECK-CPP: define{{.*}} @_Z7pr518136float2(double {{.*}}, float + return s.a; +} + +struct float3 { + float a; + struct {} s; + float b; +}; + +float pr51813_2(struct float3 s) { + // CHECK-C: define{{.*}} @pr51813_2(<2 x float> + // CHECK-CPP: define{{.*}} @_Z9pr51813_26float3(double {{.*}}, float + return s.a; +} + +struct shalf2 { + struct {} s; + _Float16 a; + _Float16 b; +}; + +_Float16 sf2(struct shalf2 s) { + // CHECK-C: define{{.*}} @sf2(<2 x half> + // CHECK-CPP: define{{.*}} @_Z3sf26shalf2(double {{.*}} + return s.a; +}; + +struct halfs2 { + _Float16 a; + struct {} s1; + _Float16 b; + struct {} s2; +}; + +_Float16 fs2(struct shalf2 s) { + // CHECK-C: define{{.*}} @fs2(<2 x half> + // CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}} + return s.a; +}; + +struct fsd { + float a; + struct {}; + double b; +}; + +struct fsd pr52011() { + // CHECK: define{{.*}} { float, double } @ +} + +struct hsd { + _Float16 a; + struct {}; + double b; +}; + +struct hsd pr52011_2() { + // CHECK: define{{.*}} { half, double } @ +} + +struct hsf { + _Float16 a; + struct {}; + float b; +}; + +struct hsf pr52011_3() { + // CHECK: define{{.*}} <4 x half> @ +} + +struct fds { + float a; + double b; + struct {}; +}; + +struct fds pr52011_4() { + // CHECK-C: define{{.*}} { float, double } @pr52011_4 + // CHECK-CPP: define{{.*}} void @_Z9pr52011_4v({{.*}} sret +} Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/fp16-complex.c =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/test/CodeGen/X86/fp16-complex.c +++ /dev/null @@ -1,134 +0,0 @@ -// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -target-feature +avx512fp16 -o - | FileCheck %s --check-prefix=X86 -// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -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; -} Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/avx512fp16-complex.c =================================================================== --- /dev/null +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/CodeGen/X86/avx512fp16-complex.c @@ -0,0 +1,133 @@ +// RUN: %clang_cc1 %s -O0 -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; +} Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/Sema/Float16.c =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/test/Sema/Float16.c +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/Sema/Float16.c @@ -1,9 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s -DHAVE +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc -target-feature +avx512fp16 %s -DHAVE // RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE // RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE -// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-pc-linux-gnu %s #ifndef HAVE // expected-error@+2{{_Float16 is not supported on this target}} Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/Sema/conversion-target-dep.c =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/test/Sema/conversion-target-dep.c +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/Sema/conversion-target-dep.c @@ -6,7 +6,7 @@ long double ld; double d; -_Float16 f16; +_Float16 f16; // x86-error {{_Float16 is not supported on this target}} int main() { ld = d; // x86-warning {{implicit conversion increases floating-point precision: 'double' to 'long double'}} Index: llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/SemaCXX/Float16.cpp =================================================================== --- llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049.orig/clang/test/SemaCXX/Float16.cpp +++ llvm-toolchain-snapshot_14~++20211123014438+e7026aba0049/clang/test/SemaCXX/Float16.cpp @@ -1,8 +1,7 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s -DHAVE +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s // RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE // RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE -// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-pc-linux-gnu %s #ifdef HAVE // expected-no-diagnostics