Skip to content

[NFC] Extend InjectTLIMappings pass testing #66898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

JolantaJensen
Copy link
Contributor

This patch adds sleefgnuabi and ArmPL vector libraries to testing of InjectTLIMappings pass.

This patch adds sleefgnuabi and ArmPL vector libraries to testing
of InjectTLIMappings pass.
@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2023

@llvm/pr-subscribers-llvm-transforms

Changes

This patch adds sleefgnuabi and ArmPL vector libraries to testing of InjectTLIMappings pass.


Full diff: https://github.com/llvm/llvm-project/pull/66898.diff

1 Files Affected:

  • (modified) llvm/test/Transforms/Util/add-TLI-mappings.ll (+13-6)
diff --git a/llvm/test/Transforms/Util/add-TLI-mappings.ll b/llvm/test/Transforms/Util/add-TLI-mappings.ll
index 8168656a6490c5b..10edbafda7d5f0a 100644
--- a/llvm/test/Transforms/Util/add-TLI-mappings.ll
+++ b/llvm/test/Transforms/Util/add-TLI-mappings.ll
@@ -2,9 +2,8 @@
 ; RUN: opt -vector-library=MASSV -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,MASSV
 ; RUN: opt -vector-library=LIBMVEC-X86 -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,LIBMVEC-X86
 ; RUN: opt -vector-library=Accelerate -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,ACCELERATE
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
+; RUN: opt -vector-library=sleefgnuabi -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=SLEEFGNUABI
+; RUN: opt -vector-library=ArmPL -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=ARMPL
 
 ; COMMON-LABEL: @llvm.compiler.used = appending global
 ; SVML-SAME:        [6 x ptr] [
@@ -30,8 +29,12 @@ define double @sin_f64(double %in) {
 ; MASSV:        call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; ACCELERATE:   call double @sin(double %{{.*}})
 ; LIBMVEC-X86:  call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
+; SLEEFGNUABI:  call double @sin(double %{{.*}})
+; ARMPL:        call double @sin(double %{{.*}})
 ; No mapping of "sin" to a vector function for Accelerate.
-; ACCELERATE-NOT: _ZGV_LLVM_{{.*}}_sin({{.*}})
+; ACCELERATE-NOT:  _ZGV_LLVM_{{.*}}_sin({{.*}})
+; SLEEFGNUABI-NOT: _ZGV_LLVM_{{.*}}_sin({{.*}})
+; ARMPL-NOT:       _ZGV_LLVM_{{.*}}_sin({{.*}})
   %call = tail call double @sin(double %in)
   ret double %call
 }
@@ -41,12 +44,16 @@ declare double @sin(double) #0
 define float @call_llvm.log10.f32(float %in) {
 ; COMMON-LABEL: @call_llvm.log10.f32(
 ; SVML:         call float @llvm.log10.f32(float %{{.*}})
-; LIBMVEC-X86:      call float @llvm.log10.f32(float %{{.*}})
+; LIBMVEC-X86:  call float @llvm.log10.f32(float %{{.*}})
 ; MASSV:        call float @llvm.log10.f32(float %{{.*}}) #[[LOG10:[0-9]+]]
 ; ACCELERATE:   call float @llvm.log10.f32(float %{{.*}}) #[[LOG10:[0-9]+]]
+; SLEEFGNUABI:  call float @llvm.log10.f32(float %{{.*}})
+; ARMPL:        call float @llvm.log10.f32(float %{{.*}})
 ; No mapping of "llvm.log10.f32" to a vector function for SVML.
-; SVML-NOT:     _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
+; SVML-NOT:        _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
 ; LIBMVEC-X86-NOT: _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
+; SLEEFGNUABI-NOT: _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
+; ARMPL-NOT:       _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
   %call = tail call float @llvm.log10.f32(float %in)
   ret float %call
 }

; No mapping of "sin" to a vector function for Accelerate.
; ACCELERATE-NOT: _ZGV_LLVM_{{.*}}_sin({{.*}})
; ACCELERATE-NOT: _ZGV_LLVM_{{.*}}_sin({{.*}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Jolanta,
Your changes to the test are wrong.
The purpose of this test is to check that the "inject-tli-mappings" pass is adding the attribute to the function call with the mappings to vector variants of the scalar call for both ARMPL and SLEEF such mappings exists so the check lines you added aren't correct.

You should also extend the check lines at the beginning and end of this file to show that the "llvm.compiler.used" array and "vector-function-abi-variant" attribute look like when ArmPL and sleefgnuabi are used.

Perhaps the target needs to be passed as opt argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the target needed to be passed as argument. Fixed.

…uabi

and ArmPL as the TLI mappings for those libraries are only initialized
for aarch64. Corrected the check lines for sleefgnuabi and ArmPL.
@@ -2,9 +2,8 @@
; RUN: opt -vector-library=MASSV -passes=inject-tli-mappings -S < %s | FileCheck %s --check-prefixes=COMMON,MASSV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the fact that MASSV, LIBMVEC or Accelerate libraries do not check if the target is correct, I think it is a good practice to specify it in the RUN line, otherwise it may lead to incorrect behaviour if something in the compiler change in the future.
So I think here we would need to add: -mtriple=powerpc64-unknown-linux-gnu here

and -mtriple=x86_64-unknown-linux-gnu in the X86 and Accelerate case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@JolantaJensen JolantaJensen merged commit 6a34b12 into llvm:main Sep 27, 2023
@JolantaJensen JolantaJensen deleted the NFC-extend-InjectTLIMappings-pass-testing branch September 28, 2023 16:04
legrosbuffle pushed a commit to legrosbuffle/llvm-project that referenced this pull request Sep 29, 2023
This patch adds sleefgnuabi and ArmPL vector libraries to testing of
InjectTLIMappings pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants