Skip to content

Commit b0564fa

Browse files
LAA cannot vectorize lib calls like modf/modff
Functions like modf/modff are math lib calls that set memory write-only attribute. Given that a target has vectorized mappings, LAA should allow vectorization.
1 parent a74ba11 commit b0564fa

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "call.*(frexp|modf)" --version 4
2+
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve -O3 -mllvm -vector-library=ArmPL -mllvm -force-vector-interleave=1 -mllvm -prefer-predicate-over-epilogue=predicate-dont-vectorize -emit-llvm -S -o - %s | FileCheck %s
3+
4+
// REQUIRES: aarch64-registered-target
5+
6+
/*
7+
Testing vectorization of math functions that have the attribute write-only to
8+
memory set. Given they have vectorized counterparts, they should be able to
9+
vectorize.
10+
*/
11+
12+
// The following define is required to access some math functions.
13+
#define _GNU_SOURCE
14+
#include <math.h>
15+
16+
// frexp/frexpf have no TLI mappings yet.
17+
18+
// CHECK-LABEL: define dso_local void @frexp_f64(
19+
// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
20+
// CHECK: [[CALL:%.*]] = tail call double @frexp(double noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR2:[0-9]+]]
21+
//
22+
void frexp_f64(double *in, double *out1, int *out2, int N) {
23+
for (int i = 0; i < N; ++i)
24+
*out1 = frexp(in[i], out2+i);
25+
}
26+
27+
// CHECK-LABEL: define dso_local void @frexp_f32(
28+
// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
29+
// CHECK: [[CALL:%.*]] = tail call float @frexpf(float noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR2]]
30+
//
31+
void frexp_f32(float *in, float *out1, int *out2, int N) {
32+
for (int i = 0; i < N; ++i)
33+
*out1 = frexpf(in[i], out2+i);
34+
}
35+
36+
37+
// TODO: LAA must allow vectorization.
38+
39+
// CHECK-LABEL: define dso_local void @modf_f64(
40+
// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
41+
// CHECK: [[CALL:%.*]] = tail call double @modf(double noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR3:[0-9]+]]
42+
//
43+
void modf_f64(double *in, double *out1, double *out2, int N) {
44+
for (int i = 0; i < N; ++i)
45+
out1[i] = modf(in[i], out2+i);
46+
}
47+
48+
// TODO: LAA must allow vectorization.
49+
50+
// CHECK-LABEL: define dso_local void @modf_f32(
51+
// CHECK-SAME: ptr nocapture noundef readonly [[IN:%.*]], ptr nocapture noundef writeonly [[OUT1:%.*]], ptr nocapture noundef writeonly [[OUT2:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
52+
// CHECK: [[CALL:%.*]] = tail call float @modff(float noundef [[TMP0:%.*]], ptr noundef [[ADD_PTR:%.*]]) #[[ATTR4:[0-9]+]]
53+
//
54+
void modf_f32(float *in, float *out1, float *out2, int N) {
55+
for (int i = 0; i < N; ++i)
56+
out1[i] = modff(in[i], out2+i);
57+
}

0 commit comments

Comments
 (0)