Skip to content

Commit 7ff8089

Browse files
Added LAA and LV tests
Removed C test. Code rebased on top of patch that enables mappings for modf/modff (among others).
1 parent 39b67b1 commit 7ff8089

File tree

4 files changed

+254
-53
lines changed

4 files changed

+254
-53
lines changed

clang/test/CodeGen/aarch64-veclib-function-calls-linear-ptrs.c

-52
This file was deleted.

llvm/lib/Analysis/LoopAccessAnalysis.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -2440,8 +2440,12 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
24402440
if (I.mayWriteToMemory()) {
24412441
// We can safety handle math functions that have vectorized
24422442
// counterparts and have the memory write-only attribute set.
2443-
if (isMathLibCallMemWriteOnly(TLI, I))
2443+
if (isMathLibCallMemWriteOnly(TLI, I)) {
2444+
LLVM_DEBUG(dbgs()
2445+
<< "LAA: allow math function with write-only attribute:"
2446+
<< I << "\n");
24442447
continue;
2448+
}
24452449

24462450
auto *St = dyn_cast<StoreInst>(&I);
24472451
if (!St) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
; RUN: opt < %s -mattr=+sve -vector-library=ArmPL -passes=inject-tli-mappings,loop-vectorize -debug-only=loop-accesses -disable-output 2>&1 | FileCheck %s
2+
3+
; REQUIRES: asserts
4+
5+
target triple = "aarch64-unknown-linux-gnu"
6+
7+
; TODO: add mappings for frexp/frexpf
8+
9+
define void @frexp_f64(ptr %in, ptr %out1, ptr %out2, i32 %N) {
10+
entry:
11+
%cmp4 = icmp sgt i32 %N, 0
12+
br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup
13+
14+
for.body.preheader:
15+
%wide.trip.count = zext nneg i32 %N to i64
16+
br label %for.body
17+
18+
for.cond.cleanup:
19+
ret void
20+
21+
for.body:
22+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
23+
%arrayidx = getelementptr inbounds double, ptr %in, i64 %indvars.iv
24+
%0 = load double, ptr %arrayidx, align 8
25+
%add.ptr = getelementptr inbounds i32, ptr %out2, i64 %indvars.iv
26+
%call = tail call double @frexp(double noundef %0, ptr noundef %add.ptr)
27+
store double %call, ptr %out1, align 8
28+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
29+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
30+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
31+
}
32+
33+
declare double @frexp(double, ptr) #1
34+
35+
define void @frexp_f32(ptr readonly %in, ptr %out1, ptr %out2, i32 %N) {
36+
entry:
37+
%cmp4 = icmp sgt i32 %N, 0
38+
br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup
39+
40+
for.body.preheader:
41+
%wide.trip.count = zext nneg i32 %N to i64
42+
br label %for.body
43+
44+
for.cond.cleanup:
45+
ret void
46+
47+
for.body:
48+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
49+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %indvars.iv
50+
%0 = load float, ptr %arrayidx, align 4
51+
%add.ptr = getelementptr inbounds i32, ptr %out2, i64 %indvars.iv
52+
%call = tail call float @frexpf(float noundef %0, ptr noundef %add.ptr)
53+
store float %call, ptr %out1, align 4
54+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
55+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
56+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
57+
}
58+
59+
declare float @frexpf(float , ptr) #1
60+
61+
define void @modf_f64(ptr %in, ptr %out1, ptr %out2, i32 %N) {
62+
; CHECK: LAA: allow math function with write-only attribute: %call = tail call double @modf
63+
entry:
64+
%cmp7 = icmp sgt i32 %N, 0
65+
br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
66+
67+
for.body.preheader:
68+
%wide.trip.count = zext nneg i32 %N to i64
69+
br label %for.body
70+
71+
for.cond.cleanup:
72+
ret void
73+
74+
for.body:
75+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
76+
%arrayidx = getelementptr inbounds double, ptr %in, i64 %indvars.iv
77+
%0 = load double, ptr %arrayidx, align 8
78+
%add.ptr = getelementptr inbounds double, ptr %out2, i64 %indvars.iv
79+
%call = tail call double @modf(double noundef %0, ptr noundef %add.ptr)
80+
%arrayidx2 = getelementptr inbounds double, ptr %out1, i64 %indvars.iv
81+
store double %call, ptr %arrayidx2, align 8
82+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
83+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
84+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
85+
}
86+
87+
declare double @modf(double , ptr ) #1
88+
89+
define void @modf_f32(ptr %in, ptr %out1, ptr %out2, i32 %N) {
90+
; CHECK: LAA: allow math function with write-only attribute: %call = tail call float @modff
91+
entry:
92+
%cmp7 = icmp sgt i32 %N, 0
93+
br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
94+
95+
for.body.preheader:
96+
%wide.trip.count = zext nneg i32 %N to i64
97+
br label %for.body
98+
99+
for.cond.cleanup:
100+
ret void
101+
102+
for.body:
103+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
104+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %indvars.iv
105+
%0 = load float, ptr %arrayidx, align 4
106+
%add.ptr = getelementptr inbounds float, ptr %out2, i64 %indvars.iv
107+
%call = tail call float @modff(float noundef %0, ptr noundef %add.ptr)
108+
%arrayidx2 = getelementptr inbounds float, ptr %out1, i64 %indvars.iv
109+
store float %call, ptr %arrayidx2, align 4
110+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
111+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
112+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
113+
}
114+
115+
declare float @modff(float noundef, ptr nocapture noundef) #1
116+
117+
attributes #1 = { memory(argmem: write) }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "call.*(frexp|modf)" --version 4
2+
; RUN: opt < %s -mattr=+sve -vector-library=ArmPL -passes=inject-tli-mappings,loop-vectorize -force-vector-interleave=1 -prefer-predicate-over-epilogue=predicate-dont-vectorize -S | FileCheck %s
3+
4+
target triple = "aarch64-unknown-linux-gnu"
5+
6+
; TODO: add mappings for frexp/frexpf
7+
8+
define void @frexp_f64(ptr %in, ptr %out1, ptr %out2, i32 %N) {
9+
; CHECK-LABEL: define void @frexp_f64(
10+
; CHECK-SAME: ptr [[IN:%.*]], ptr [[OUT1:%.*]], ptr [[OUT2:%.*]], i32 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
11+
; CHECK: [[CALL:%.*]] = tail call double @frexp(double noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]])
12+
;
13+
entry:
14+
%cmp4 = icmp sgt i32 %N, 0
15+
br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup
16+
17+
for.body.preheader:
18+
%wide.trip.count = zext nneg i32 %N to i64
19+
br label %for.body
20+
21+
for.cond.cleanup:
22+
ret void
23+
24+
for.body:
25+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
26+
%arrayidx = getelementptr inbounds double, ptr %in, i64 %indvars.iv
27+
%0 = load double, ptr %arrayidx, align 8
28+
%add.ptr = getelementptr inbounds i32, ptr %out2, i64 %indvars.iv
29+
%call = tail call double @frexp(double noundef %0, ptr noundef %add.ptr)
30+
store double %call, ptr %out1, align 8
31+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
32+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
33+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
34+
}
35+
36+
declare double @frexp(double, ptr) #1
37+
38+
define void @frexp_f32(ptr readonly %in, ptr %out1, ptr %out2, i32 %N) {
39+
; CHECK-LABEL: define void @frexp_f32(
40+
; CHECK-SAME: ptr readonly [[IN:%.*]], ptr [[OUT1:%.*]], ptr [[OUT2:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
41+
; CHECK: [[CALL:%.*]] = tail call float @frexpf(float noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]])
42+
;
43+
entry:
44+
%cmp4 = icmp sgt i32 %N, 0
45+
br i1 %cmp4, label %for.body.preheader, label %for.cond.cleanup
46+
47+
for.body.preheader:
48+
%wide.trip.count = zext nneg i32 %N to i64
49+
br label %for.body
50+
51+
for.cond.cleanup:
52+
ret void
53+
54+
for.body:
55+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
56+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %indvars.iv
57+
%0 = load float, ptr %arrayidx, align 4
58+
%add.ptr = getelementptr inbounds i32, ptr %out2, i64 %indvars.iv
59+
%call = tail call float @frexpf(float noundef %0, ptr noundef %add.ptr)
60+
store float %call, ptr %out1, align 4
61+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
62+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
63+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
64+
}
65+
66+
declare float @frexpf(float , ptr) #1
67+
68+
define void @modf_f64(ptr %in, ptr %out1, ptr %out2, i32 %N) {
69+
; CHECK-LABEL: define void @modf_f64(
70+
; CHECK-SAME: ptr [[IN:%.*]], ptr [[OUT1:%.*]], ptr [[OUT2:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
71+
; CHECK: [[TMP27:%.*]] = call <vscale x 2 x double> @armpl_svmodf_f64_x(<vscale x 2 x double> [[WIDE_MASKED_LOAD:%.*]], ptr [[TMP26:%.*]], <vscale x 2 x i1> [[ACTIVE_LANE_MASK:%.*]])
72+
; CHECK: [[CALL:%.*]] = tail call double @modf(double noundef [[TMP32:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR5:[0-9]+]]
73+
;
74+
entry:
75+
%cmp7 = icmp sgt i32 %N, 0
76+
br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
77+
78+
for.body.preheader:
79+
%wide.trip.count = zext nneg i32 %N to i64
80+
br label %for.body
81+
82+
for.cond.cleanup:
83+
ret void
84+
85+
for.body:
86+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
87+
%arrayidx = getelementptr inbounds double, ptr %in, i64 %indvars.iv
88+
%0 = load double, ptr %arrayidx, align 8
89+
%add.ptr = getelementptr inbounds double, ptr %out2, i64 %indvars.iv
90+
%call = tail call double @modf(double noundef %0, ptr noundef %add.ptr)
91+
%arrayidx2 = getelementptr inbounds double, ptr %out1, i64 %indvars.iv
92+
store double %call, ptr %arrayidx2, align 8
93+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
94+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
95+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
96+
}
97+
98+
declare double @modf(double , ptr ) #1
99+
100+
define void @modf_f32(ptr %in, ptr %out1, ptr %out2, i32 %N) {
101+
; CHECK-LABEL: define void @modf_f32(
102+
; CHECK-SAME: ptr [[IN:%.*]], ptr [[OUT1:%.*]], ptr [[OUT2:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
103+
; CHECK: [[TMP27:%.*]] = call <vscale x 4 x float> @armpl_svmodf_f32_x(<vscale x 4 x float> [[WIDE_MASKED_LOAD:%.*]], ptr [[TMP26:%.*]], <vscale x 4 x i1> [[ACTIVE_LANE_MASK:%.*]])
104+
; CHECK: [[CALL:%.*]] = tail call float @modff(float noundef [[TMP32:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR6:[0-9]+]]
105+
;
106+
entry:
107+
%cmp7 = icmp sgt i32 %N, 0
108+
br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup
109+
110+
for.body.preheader:
111+
%wide.trip.count = zext nneg i32 %N to i64
112+
br label %for.body
113+
114+
for.cond.cleanup:
115+
ret void
116+
117+
for.body:
118+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
119+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %indvars.iv
120+
%0 = load float, ptr %arrayidx, align 4
121+
%add.ptr = getelementptr inbounds float, ptr %out2, i64 %indvars.iv
122+
%call = tail call float @modff(float noundef %0, ptr noundef %add.ptr)
123+
%arrayidx2 = getelementptr inbounds float, ptr %out1, i64 %indvars.iv
124+
store float %call, ptr %arrayidx2, align 4
125+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
126+
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
127+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
128+
}
129+
130+
declare float @modff(float noundef, ptr nocapture noundef) #1
131+
132+
attributes #1 = { memory(argmem: write) }

0 commit comments

Comments
 (0)