Skip to content

Commit aae0f27

Browse files
pawosm-armbryanpkc
authored andcommitted
[llvm] Provide separate veclib mapping of PGMATH functions for AArch64
This patch fixes link-time issues experienced while compiling some more obscure Fortran workloads. For those programs, calls to the libpgmath functions not defined for AArch64 were generated, e.g. `__pg_log_4` or `__fd_log_4`. This patch eliminates such possibility. Signed-off-by: Paul Osmialowski <[email protected]>
1 parent 8141e0a commit aae0f27

File tree

5 files changed

+755
-448
lines changed

5 files changed

+755
-448
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
; REQUIRES: aarch64-registered-target
2+
3+
; RUN: %clang -target aarch64-unknown-linux-gnu -Ofast -S %s -o - | FileCheck %s
4+
5+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6+
7+
define void @fun_(i64* nocapture %z) local_unnamed_addr #0 {
8+
L.entry:
9+
%0 = bitcast i64* %z to i8*
10+
%1 = bitcast i64* %z to float*
11+
%2 = load float, float* %1, align 4
12+
%3 = fpext float %2 to double
13+
%4 = fadd double %3, 5.000000e-01
14+
%5 = tail call double @__pd_log_1(double %4) #1
15+
%6 = fptrunc double %5 to float
16+
%7 = tail call float @__ps_exp_1(float %6) #2
17+
store float %7, float* %1, align 4
18+
%8 = getelementptr i8, i8* %0, i64 4
19+
%9 = bitcast i8* %8 to float*
20+
%10 = load float, float* %9, align 4
21+
%11 = fpext float %10 to double
22+
%12 = fadd double %11, 5.000000e-01
23+
%13 = tail call double @__pd_log_1(double %12) #1
24+
%14 = fptrunc double %13 to float
25+
%15 = tail call float @__ps_exp_1(float %14) #2
26+
store float %15, float* %9, align 4
27+
%16 = getelementptr i64, i64* %z, i64 1
28+
%17 = bitcast i64* %16 to float*
29+
%18 = load float, float* %17, align 4
30+
%19 = fpext float %18 to double
31+
%20 = fadd double %19, 5.000000e-01
32+
%21 = tail call double @__pd_log_1(double %20) #1
33+
%22 = fptrunc double %21 to float
34+
%23 = tail call float @__ps_exp_1(float %22) #2
35+
store float %23, float* %17, align 4
36+
%24 = getelementptr i8, i8* %0, i64 12
37+
%25 = bitcast i8* %24 to float*
38+
%26 = load float, float* %25, align 4
39+
%27 = fpext float %26 to double
40+
%28 = fadd double %27, 5.000000e-01
41+
%29 = tail call double @__pd_log_1(double %28) #1
42+
%30 = fptrunc double %29 to float
43+
%31 = tail call float @__ps_exp_1(float %30) #2
44+
store float %31, float* %25, align 4
45+
ret void
46+
47+
; CHECK-NOT: __pd_log_4
48+
; CHECK: __pd_log_1
49+
; CHECK: __pd_log_1
50+
; CHECK: __pd_log_1
51+
; CHECK: __pd_log_1
52+
}
53+
54+
; Function Attrs: nounwind readnone willreturn
55+
declare float @__ps_exp_1(float) #0
56+
57+
; Function Attrs: nounwind readnone willreturn
58+
declare double @__pd_log_1(double) #0
59+
60+
attributes #0 = { nounwind readnone willreturn }
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
; REQUIRES: x86-registered-target
2+
3+
; RUN: %clang -target x86_64-unknown-linux-gnu -msse -Ofast -S %s -o - | FileCheck %s
4+
5+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6+
7+
define void @fun_(i64* nocapture %z) local_unnamed_addr #0 {
8+
L.entry:
9+
%0 = bitcast i64* %z to i8*
10+
%1 = bitcast i64* %z to float*
11+
%2 = load float, float* %1, align 4
12+
%3 = fpext float %2 to double
13+
%4 = fadd double %3, 5.000000e-01
14+
%5 = tail call double @__pd_log_1(double %4) #1
15+
%6 = fptrunc double %5 to float
16+
%7 = tail call float @__ps_exp_1(float %6) #2
17+
store float %7, float* %1, align 4
18+
%8 = getelementptr i8, i8* %0, i64 4
19+
%9 = bitcast i8* %8 to float*
20+
%10 = load float, float* %9, align 4
21+
%11 = fpext float %10 to double
22+
%12 = fadd double %11, 5.000000e-01
23+
%13 = tail call double @__pd_log_1(double %12) #1
24+
%14 = fptrunc double %13 to float
25+
%15 = tail call float @__ps_exp_1(float %14) #2
26+
store float %15, float* %9, align 4
27+
%16 = getelementptr i64, i64* %z, i64 1
28+
%17 = bitcast i64* %16 to float*
29+
%18 = load float, float* %17, align 4
30+
%19 = fpext float %18 to double
31+
%20 = fadd double %19, 5.000000e-01
32+
%21 = tail call double @__pd_log_1(double %20) #1
33+
%22 = fptrunc double %21 to float
34+
%23 = tail call float @__ps_exp_1(float %22) #2
35+
store float %23, float* %17, align 4
36+
%24 = getelementptr i8, i8* %0, i64 12
37+
%25 = bitcast i8* %24 to float*
38+
%26 = load float, float* %25, align 4
39+
%27 = fpext float %26 to double
40+
%28 = fadd double %27, 5.000000e-01
41+
%29 = tail call double @__pd_log_1(double %28) #1
42+
%30 = fptrunc double %29 to float
43+
%31 = tail call float @__ps_exp_1(float %30) #2
44+
store float %31, float* %25, align 4
45+
ret void
46+
47+
; CHECK-NOT: __pd_log_1
48+
; CHECK: __pd_log_4
49+
}
50+
51+
; Function Attrs: nounwind readnone willreturn
52+
declare float @__ps_exp_1(float) #0
53+
54+
; Function Attrs: nounwind readnone willreturn
55+
declare double @__pd_log_1(double) #0
56+
57+
attributes #0 = { nounwind readnone willreturn }

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace llvm {
2222
template <typename T> class ArrayRef;
2323
class Function;
2424
class Module;
25-
class Triple;
2625

2726
/// Provides info so a possible vectorization of a function can be
2827
/// computed. Function 'VectorFnName' is equivalent to 'ScalarFnName'
@@ -113,6 +112,8 @@ class TargetLibraryInfoImpl {
113112
bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F,
114113
const Module &M) const;
115114

115+
Triple T;
116+
116117
public:
117118
/// List of known vector-functions libraries.
118119
///

0 commit comments

Comments
 (0)