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

2024-02-14 Thread via cfe-commits

https://github.com/ganeshgit closed 
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)

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

https://github.com/phoebewang approved this pull request.

LGTM.

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)

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


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

phoebewang wrote:

Sorry, it's some display problem in my side. I took it adding one more blank 
during the review.

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)

2024-01-19 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:

Add RUNs for avx2 / avx512 capable targets to ensure amd_vrs8_expf / 
amd_vrs16_expf etc. are used when appropriate? 

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)

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


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


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

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


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

phoebewang wrote:

Fix the format here

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)

2024-01-18 Thread Phoebe Wang 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

phoebewang wrote:

Add comment?

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)

2024-01-18 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Rohit Aggarwal (rohitaggarwal007)


Changes

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.



---

Patch is 60.65 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/78560.diff


11 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+2-2) 
- (modified) clang/test/Driver/autocomplete.c (+1) 
- (modified) llvm/include/llvm/Analysis/TargetLibraryInfo.h (+2-1) 
- (modified) llvm/include/llvm/Frontend/Driver/CodeGenOptions.h (+2-1) 
- (modified) llvm/lib/Analysis/TargetLibraryInfo.cpp (+210-1) 
- (modified) llvm/lib/Frontend/Driver/CodeGenOptions.cpp (+4) 
- (modified) llvm/test/CodeGen/Generic/replace-intrinsics-with-veclib.ll (+11) 
- (added) llvm/test/Transforms/LoopVectorize/X86/amdlibm-calls-finite.ll (+332) 
- (added) llvm/test/Transforms/LoopVectorize/X86/amdlibm-calls.ll (+747) 
- (modified) llvm/test/Transforms/SLPVectorizer/X86/sin-sqrt.ll (+28-1) 
- (modified) llvm/test/Transforms/Util/add-TLI-mappings.ll (+23) 


``diff
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 ,
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 
TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
 }
 break;
   }
+  case AMDLIBM: {
+#define FIXED(NL) ElementCount::getFixed(NL)
+

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

2024-01-18 Thread via cfe-commits

github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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)

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

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