[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)

2024-01-31 Thread Simon Pilgrim via cfe-commits


@@ -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

RKSimon wrote:

I'm still not seeing cases where the vector width is varying depending on cpu 
abilities?

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)

2024-01-30 Thread Rohit Aggarwal via cfe-commits


@@ -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)

2024-01-30 Thread Rohit Aggarwal via cfe-commits


@@ -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)

2024-01-30 Thread Rohit Aggarwal via cfe-commits


@@ -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)

2024-01-30 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff f1226eea52e21b6325cf24cf0d7ccd6a517baee5 
4fdcf97e7fc1f60ab851045a16c827ecfe2e5d31 -- clang/test/Driver/autocomplete.c 
llvm/include/llvm/Analysis/TargetLibraryInfo.h 
llvm/include/llvm/Frontend/Driver/CodeGenOptions.h 
llvm/lib/Analysis/TargetLibraryInfo.cpp 
llvm/lib/Frontend/Driver/CodeGenOptions.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h 
b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index ac184de84d..46f31f918e 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -130,7 +130,7 @@ public:
 SVML, // Intel short vector math library.
 SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions.
 ArmPL,   // Arm Performance Libraries.
-AMDLIBM   // AMD Math Vector library.
+AMDLIBM  // AMD Math Vector library.
   };
 
   TargetLibraryInfoImpl();

``




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)

2024-01-30 Thread Rohit Aggarwal via cfe-commits

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 ,
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[] = {
+

[llvm] [clang] Adding support of AMDLIBM vector library (PR #78560)

2024-01-18 Thread Phoebe Wang via cfe-commits


@@ -1279,6 +1281,213 @@ void 
TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
 }
 break;
   }
+  case AMDLIBM: {
+#define FIXED(NL) ElementCount::getFixed(NL)
+const VecDesc VecFuncs[] = {

phoebewang wrote:

Move them to `VecFuncs.def`?

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)

2024-01-18 Thread Rohit Aggarwal via cfe-commits

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