[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)
@@ -0,0 +1,332 @@ +; RUN: opt -vector-library=AMDLIBM -passes=inject-tli-mappings,loop-vectorize -S < %s | FileCheck %s + +; Test to verify that when math headers are built with +; __FINITE_MATH_ONLY__ enabled, causing use of ___finite +; function versions, vectorization can map these to vector versions. + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare float @__expf_finite(float) #0 + +; CHECK-LABEL: @exp_f32 +; CHECK: <4 x float> @amd_vrs4_expf rohitaggarwal007 wrote: Added RUN for avx512 in amdlibm-calls.ll https://github.com/llvm/llvm-project/pull/78560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)
@@ -1279,6 +1281,213 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib( } break; } + case AMDLIBM: { +#define FIXED(NL) ElementCount::getFixed(NL) +const VecDesc VecFuncs[] = { rohitaggarwal007 wrote: done https://github.com/llvm/llvm-project/pull/78560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)
@@ -129,7 +129,8 @@ class TargetLibraryInfoImpl { MASSV,// IBM MASS vector library. SVML, // Intel short vector math library. SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions. -ArmPL// Arm Performance Libraries. +ArmPL, // Arm Performance Libraries. +AMDLIBM rohitaggarwal007 wrote: done https://github.com/llvm/llvm-project/pull/78560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)
https://github.com/rohitaggarwal007 updated https://github.com/llvm/llvm-project/pull/78560 >From d2e001b9f6b174b6313f99c4a094ab3714548806 Mon Sep 17 00:00:00 2001 From: Rohit Aggarwal Date: Thu, 18 Jan 2024 14:03:50 +0530 Subject: [PATCH 1/2] Adding support of AMDLIBM vector library --- clang/include/clang/Driver/Options.td | 4 +- clang/test/Driver/autocomplete.c | 1 + .../include/llvm/Analysis/TargetLibraryInfo.h | 3 +- .../llvm/Frontend/Driver/CodeGenOptions.h | 3 +- llvm/lib/Analysis/TargetLibraryInfo.cpp | 211 - llvm/lib/Frontend/Driver/CodeGenOptions.cpp | 4 + .../Generic/replace-intrinsics-with-veclib.ll | 11 + .../LoopVectorize/X86/amdlibm-calls-finite.ll | 332 .../LoopVectorize/X86/amdlibm-calls.ll| 747 ++ .../Transforms/SLPVectorizer/X86/sin-sqrt.ll | 29 +- llvm/test/Transforms/Util/add-TLI-mappings.ll | 23 + 11 files changed, 1362 insertions(+), 6 deletions(-) create mode 100644 llvm/test/Transforms/LoopVectorize/X86/amdlibm-calls-finite.ll create mode 100644 llvm/test/Transforms/LoopVectorize/X86/amdlibm-calls.ll diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e4fdad8265c86..2fbe1f49a79aa 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3190,10 +3190,10 @@ def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group, - Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,none">, + Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">, NormalizedValuesScope<"llvm::driver::VectorLibrary">, NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "SLEEF", - "Darwin_libsystem_m", "ArmPL", "NoLibrary"]>, + "Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>, MarshallingInfoEnum, "NoLibrary">; def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group, Alias, AliasArgs<["none"]>; diff --git a/clang/test/Driver/autocomplete.c b/clang/test/Driver/autocomplete.c index d6f57708b67eb..c8ceaaf404672 100644 --- a/clang/test/Driver/autocomplete.c +++ b/clang/test/Driver/autocomplete.c @@ -80,6 +80,7 @@ // FLTOALL-NEXT: thin // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL // FVECLIBALL: Accelerate +// FVECLIBALL-NEXT: AMDLIBM // FVECLIBALL-NEXT: ArmPL // FVECLIBALL-NEXT: Darwin_libsystem_m // FVECLIBALL-NEXT: libmvec diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h index daf1d8e2079f8..4a3edb8f02a7a 100644 --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h @@ -129,7 +129,8 @@ class TargetLibraryInfoImpl { MASSV,// IBM MASS vector library. SVML, // Intel short vector math library. SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions. -ArmPL// Arm Performance Libraries. +ArmPL, // Arm Performance Libraries. +AMDLIBM }; TargetLibraryInfoImpl(); diff --git a/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h b/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h index 0b1d924a26b2d..0180670c4c699 100644 --- a/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h +++ b/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h @@ -29,7 +29,8 @@ enum class VectorLibrary { SVML, // Intel short vector math library. SLEEF, // SLEEF SIMD Library for Evaluating Elementary Functions. Darwin_libsystem_m, // Use Darwin's libsystem_m vector functions. - ArmPL // Arm Performance Libraries. + ArmPL, // Arm Performance Libraries. + AMDLIBM // AMD vector math library. }; TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple, diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index 58749e559040a..16afc33bf7ce8 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -37,7 +37,9 @@ static cl::opt ClVectorLibrary( clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi", "SIMD Library for Evaluating Elementary Functions"), clEnumValN(TargetLibraryInfoImpl::ArmPL, "ArmPL", - "Arm Performance Libraries"))); + "Arm Performance Libraries"), + clEnumValN(TargetLibraryInfoImpl::AMDLIBM, "AMDLIBM", + "AMD vector math library"))); StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = { @@ -1279,6 +1281,213 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib( } break; } + case AMDLIBM: { +#define FIXED(NL) ElementCount::getFixed(NL) +const VecDesc VecFuncs[]
[clang] [llvm] Adding support of AMDLIBM vector library (PR #78560)
https://github.com/rohitaggarwal007 created https://github.com/llvm/llvm-project/pull/78560 Hi, AMD has it's own implementation of vector calls. This patch include the changes to enable the use of AMD's math library using -fveclib=AMDLIBM. >From d2e001b9f6b174b6313f99c4a094ab3714548806 Mon Sep 17 00:00:00 2001 From: Rohit Aggarwal Date: Thu, 18 Jan 2024 14:03:50 +0530 Subject: [PATCH] Adding support of AMDLIBM vector library --- clang/include/clang/Driver/Options.td | 4 +- clang/test/Driver/autocomplete.c | 1 + .../include/llvm/Analysis/TargetLibraryInfo.h | 3 +- .../llvm/Frontend/Driver/CodeGenOptions.h | 3 +- llvm/lib/Analysis/TargetLibraryInfo.cpp | 211 - llvm/lib/Frontend/Driver/CodeGenOptions.cpp | 4 + .../Generic/replace-intrinsics-with-veclib.ll | 11 + .../LoopVectorize/X86/amdlibm-calls-finite.ll | 332 .../LoopVectorize/X86/amdlibm-calls.ll| 747 ++ .../Transforms/SLPVectorizer/X86/sin-sqrt.ll | 29 +- llvm/test/Transforms/Util/add-TLI-mappings.ll | 23 + 11 files changed, 1362 insertions(+), 6 deletions(-) create mode 100644 llvm/test/Transforms/LoopVectorize/X86/amdlibm-calls-finite.ll create mode 100644 llvm/test/Transforms/LoopVectorize/X86/amdlibm-calls.ll diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e4fdad8265c863..2fbe1f49a79aab 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3190,10 +3190,10 @@ def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group, - Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,none">, + Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">, NormalizedValuesScope<"llvm::driver::VectorLibrary">, NormalizedValues<["Accelerate", "LIBMVEC", "MASSV", "SVML", "SLEEF", - "Darwin_libsystem_m", "ArmPL", "NoLibrary"]>, + "Darwin_libsystem_m", "ArmPL", "AMDLIBM", "NoLibrary"]>, MarshallingInfoEnum, "NoLibrary">; def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group, Alias, AliasArgs<["none"]>; diff --git a/clang/test/Driver/autocomplete.c b/clang/test/Driver/autocomplete.c index d6f57708b67eb6..c8ceaaf404672f 100644 --- a/clang/test/Driver/autocomplete.c +++ b/clang/test/Driver/autocomplete.c @@ -80,6 +80,7 @@ // FLTOALL-NEXT: thin // RUN: %clang --autocomplete=-fveclib= | FileCheck %s -check-prefix=FVECLIBALL // FVECLIBALL: Accelerate +// FVECLIBALL-NEXT: AMDLIBM // FVECLIBALL-NEXT: ArmPL // FVECLIBALL-NEXT: Darwin_libsystem_m // FVECLIBALL-NEXT: libmvec diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h index daf1d8e2079f85..4a3edb8f02a7a8 100644 --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h @@ -129,7 +129,8 @@ class TargetLibraryInfoImpl { MASSV,// IBM MASS vector library. SVML, // Intel short vector math library. SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions. -ArmPL// Arm Performance Libraries. +ArmPL, // Arm Performance Libraries. +AMDLIBM }; TargetLibraryInfoImpl(); diff --git a/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h b/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h index 0b1d924a26b2de..0180670c4c6991 100644 --- a/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h +++ b/llvm/include/llvm/Frontend/Driver/CodeGenOptions.h @@ -29,7 +29,8 @@ enum class VectorLibrary { SVML, // Intel short vector math library. SLEEF, // SLEEF SIMD Library for Evaluating Elementary Functions. Darwin_libsystem_m, // Use Darwin's libsystem_m vector functions. - ArmPL // Arm Performance Libraries. + ArmPL, // Arm Performance Libraries. + AMDLIBM // AMD vector math library. }; TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple, diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index 58749e559040a7..16afc33bf7ce88 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -37,7 +37,9 @@ static cl::opt ClVectorLibrary( clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi", "SIMD Library for Evaluating Elementary Functions"), clEnumValN(TargetLibraryInfoImpl::ArmPL, "ArmPL", - "Arm Performance Libraries"))); + "Arm Performance Libraries"), + clEnumValN(TargetLibraryInfoImpl::AMDLIBM, "AMDLIBM", + "AMD vector math library"))); StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = { @@ -1279,6 +1281,213 @@ void TargetLibraryInfoIm
[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)
rohitaggarwal007 wrote: @florianhumblot @alexey-bataev @RKSimon @phoebewang Please review the pull request. https://github.com/llvm/llvm-project/pull/78560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Adding support of AMDLIBM vector library (PR #78560)
@@ -3190,10 +3190,10 @@ def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group, - Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,none">, + Values<"Accelerate,libmvec,MASSV,SVML,SLEEF,Darwin_libsystem_m,ArmPL,AMDLIBM,none">, rohitaggarwal007 wrote: I did not understood the comment. you meant to say formatting? https://github.com/llvm/llvm-project/pull/78560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits