Skip to content

Commit afeb08f

Browse files
committed
Add target-independent tests + fixups
1 parent 25717a1 commit afeb08f

File tree

2 files changed

+159
-2
lines changed

2 files changed

+159
-2
lines changed

llvm/test/Transforms/LoopVectorize/AArch64/llvm.sincos.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|extractvalue|store)" --version 5
22
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve < %s -S -o - -debug-only=loop-vectorize 2>%t.1 | FileCheck %s --check-prefix=CHECK
33
; RUN: opt -passes=loop-vectorize -mtriple=aarch64-gnu-linux -mcpu=neoverse-v1 -mattr=+sve -vector-library=ArmPL < %s -S -o - -debug-only=loop-vectorize 2>%t.2 | FileCheck %s --check-prefix=CHECK-ARMPL
4-
; RUN: cat %t.1 | FileCheck --check-prefix=CHECK-COST %s
5-
; RUN: cat %t.2 | FileCheck --check-prefix=CHECK-COST-ARMPL %s
4+
; RUN: FileCheck --input-file=%t.1 --check-prefix=CHECK-COST %s
5+
; RUN: FileCheck --input-file=%t.2 --check-prefix=CHECK-COST-ARMPL %s
66
; REQUIRES: asserts
77

88
; CHECK-COST-LABEL: sincos_f32
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|extract|store)" --version 5
2+
; RUN: opt -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 < %s -S -o - | FileCheck %s
3+
4+
define void @sincos_f32(ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) {
5+
; CHECK-LABEL: define void @sincos_f32(
6+
; CHECK-SAME: ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) {
7+
; CHECK: [[ENTRY:.*:]]
8+
; CHECK: [[VECTOR_PH:.*:]]
9+
; CHECK: [[VECTOR_BODY:.*:]]
10+
; CHECK: [[TMP3:%.*]] = call { <2 x float>, <2 x float> } @llvm.sincos.v2f32(<2 x float> [[WIDE_LOAD:%.*]])
11+
; CHECK: [[TMP4:%.*]] = extractvalue { <2 x float>, <2 x float> } [[TMP3]], 0
12+
; CHECK: [[TMP5:%.*]] = extractvalue { <2 x float>, <2 x float> } [[TMP3]], 1
13+
; CHECK: store <2 x float> [[TMP4]], ptr [[TMP7:%.*]], align 4
14+
; CHECK: store <2 x float> [[TMP5]], ptr [[TMP9:%.*]], align 4
15+
; CHECK: [[MIDDLE_BLOCK:.*:]]
16+
; CHECK: [[SCALAR_PH:.*:]]
17+
; CHECK: [[FOR_BODY:.*:]]
18+
; CHECK: [[CALL:%.*]] = tail call { float, float } @llvm.sincos.f32(float [[IN_VAL:%.*]])
19+
; CHECK: [[EXTRACT_A:%.*]] = extractvalue { float, float } [[CALL]], 0
20+
; CHECK: [[EXTRACT_B:%.*]] = extractvalue { float, float } [[CALL]], 1
21+
; CHECK: store float [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 4
22+
; CHECK: store float [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 4
23+
; CHECK: [[EXIT:.*:]]
24+
;
25+
entry:
26+
br label %for.body
27+
28+
for.body:
29+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
30+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %iv
31+
%in_val = load float, ptr %arrayidx, align 4
32+
%call = tail call { float, float } @llvm.sincos.f32(float %in_val)
33+
%extract_a = extractvalue { float, float } %call, 0
34+
%extract_b = extractvalue { float, float } %call, 1
35+
%arrayidx2 = getelementptr inbounds float, ptr %out_a, i64 %iv
36+
store float %extract_a, ptr %arrayidx2, align 4
37+
%arrayidx4 = getelementptr inbounds float, ptr %out_b, i64 %iv
38+
store float %extract_b, ptr %arrayidx4, align 4
39+
%iv.next = add nuw nsw i64 %iv, 1
40+
%exitcond.not = icmp eq i64 %iv.next, 1024
41+
br i1 %exitcond.not, label %exit, label %for.body
42+
43+
exit:
44+
ret void
45+
}
46+
47+
define void @sincos_f64(ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) {
48+
; CHECK-LABEL: define void @sincos_f64(
49+
; CHECK-SAME: ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) {
50+
; CHECK: [[ENTRY:.*:]]
51+
; CHECK: [[VECTOR_PH:.*:]]
52+
; CHECK: [[VECTOR_BODY:.*:]]
53+
; CHECK: [[TMP3:%.*]] = call { <2 x double>, <2 x double> } @llvm.sincos.v2f64(<2 x double> [[WIDE_LOAD:%.*]])
54+
; CHECK: [[TMP4:%.*]] = extractvalue { <2 x double>, <2 x double> } [[TMP3]], 0
55+
; CHECK: [[TMP5:%.*]] = extractvalue { <2 x double>, <2 x double> } [[TMP3]], 1
56+
; CHECK: store <2 x double> [[TMP4]], ptr [[TMP7:%.*]], align 8
57+
; CHECK: store <2 x double> [[TMP5]], ptr [[TMP9:%.*]], align 8
58+
; CHECK: [[MIDDLE_BLOCK:.*:]]
59+
; CHECK: [[SCALAR_PH:.*:]]
60+
; CHECK: [[FOR_BODY:.*:]]
61+
; CHECK: [[CALL:%.*]] = tail call { double, double } @llvm.sincos.f64(double [[IN_VAL:%.*]])
62+
; CHECK: [[EXTRACT_A:%.*]] = extractvalue { double, double } [[CALL]], 0
63+
; CHECK: [[EXTRACT_B:%.*]] = extractvalue { double, double } [[CALL]], 1
64+
; CHECK: store double [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 8
65+
; CHECK: store double [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 8
66+
; CHECK: [[EXIT:.*:]]
67+
;
68+
entry:
69+
br label %for.body
70+
71+
for.body:
72+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
73+
%arrayidx = getelementptr inbounds double, ptr %in, i64 %iv
74+
%in_val = load double, ptr %arrayidx, align 8
75+
%call = tail call { double, double } @llvm.sincos.f64(double %in_val)
76+
%extract_a = extractvalue { double, double } %call, 0
77+
%extract_b = extractvalue { double, double } %call, 1
78+
%arrayidx2 = getelementptr inbounds double, ptr %out_a, i64 %iv
79+
store double %extract_a, ptr %arrayidx2, align 8
80+
%arrayidx4 = getelementptr inbounds double, ptr %out_b, i64 %iv
81+
store double %extract_b, ptr %arrayidx4, align 8
82+
%iv.next = add nuw nsw i64 %iv, 1
83+
%exitcond.not = icmp eq i64 %iv.next, 1024
84+
br i1 %exitcond.not, label %exit, label %for.body
85+
86+
exit:
87+
ret void
88+
}
89+
90+
define void @predicated_sincos(float %x, ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) {
91+
; CHECK-LABEL: define void @predicated_sincos(
92+
; CHECK-SAME: float [[X:%.*]], ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) {
93+
; CHECK: [[ENTRY:.*:]]
94+
; CHECK: [[VECTOR_BODY1:.*]]:
95+
; CHECK: [[VECTOR_BODY:.*:]]
96+
; CHECK: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_BODY1]] ], [ [[INDEX_NEXT:%.*]], %[[FOR_BODY1:.*]] ]
97+
; CHECK: [[TMP4:%.*]] = call { <2 x float>, <2 x float> } @llvm.sincos.v2f32(<2 x float> [[WIDE_LOAD:%.*]])
98+
; CHECK: [[TMP5:%.*]] = extractvalue { <2 x float>, <2 x float> } [[TMP4]], 0
99+
; CHECK: [[TMP6:%.*]] = extractvalue { <2 x float>, <2 x float> } [[TMP4]], 1
100+
; CHECK: [[TMP7:%.*]] = extractelement <2 x i1> [[TMP3:%.*]], i32 0
101+
; CHECK: br i1 [[TMP7]], label %[[PRED_STORE_IF:.*]], label %[[PRED_STORE_CONTINUE:.*]]
102+
; CHECK: [[PRED_STORE_IF]]:
103+
; CHECK: [[TMP9:%.*]] = extractelement <2 x float> [[TMP5]], i32 0
104+
; CHECK: store float [[TMP9]], ptr [[TMP8:%.*]], align 4
105+
; CHECK: [[TMP11:%.*]] = extractelement <2 x float> [[TMP6]], i32 0
106+
; CHECK: store float [[TMP11]], ptr [[TMP10:%.*]], align 4
107+
; CHECK: br label %[[PRED_STORE_CONTINUE]]
108+
; CHECK: [[PRED_STORE_CONTINUE]]:
109+
; CHECK: [[TMP12:%.*]] = extractelement <2 x i1> [[TMP3]], i32 1
110+
; CHECK: br i1 [[TMP12]], label %[[PRED_STORE_IF1:.*]], label %[[FOR_BODY1]]
111+
; CHECK: [[PRED_STORE_IF1]]:
112+
; CHECK: [[TMP15:%.*]] = extractelement <2 x float> [[TMP5]], i32 1
113+
; CHECK: store float [[TMP15]], ptr [[TMP14:%.*]], align 4
114+
; CHECK: [[TMP17:%.*]] = extractelement <2 x float> [[TMP6]], i32 1
115+
; CHECK: store float [[TMP17]], ptr [[TMP16:%.*]], align 4
116+
; CHECK: br label %[[FOR_BODY1]]
117+
; CHECK: [[FOR_BODY1]]:
118+
; CHECK: [[IF_THEN1:.*:]]
119+
; CHECK: [[IF_THEN2:.*:]]
120+
; CHECK: [[IF_THEN:.*:]]
121+
; CHECK: [[IF_THEN3:.*:]]
122+
; CHECK: [[CALL:%.*]] = tail call { float, float } @llvm.sincos.f32(float [[IN_VAL:%.*]])
123+
; CHECK: [[EXTRACT_A:%.*]] = extractvalue { float, float } [[CALL]], 0
124+
; CHECK: [[EXTRACT_B:%.*]] = extractvalue { float, float } [[CALL]], 1
125+
; CHECK: store float [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 4
126+
; CHECK: store float [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 4
127+
; CHECK: [[IF_MERGE:.*:]]
128+
; CHECK: [[FOR_END:.*:]]
129+
;
130+
entry:
131+
br label %for.body
132+
133+
for.body:
134+
%iv = phi i64 [ %iv.next, %if.merge ], [ 0, %entry ]
135+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %iv
136+
%in_val = load float, ptr %arrayidx, align 4
137+
%if_cond = fcmp olt float %in_val, %x
138+
br i1 %if_cond, label %if.then, label %if.merge
139+
140+
if.then:
141+
%call = tail call { float, float } @llvm.sincos.f32(float %in_val)
142+
%extract_a = extractvalue { float, float } %call, 0
143+
%extract_b = extractvalue { float, float } %call, 1
144+
%arrayidx2 = getelementptr inbounds float, ptr %out_a, i64 %iv
145+
store float %extract_a, ptr %arrayidx2, align 4
146+
%arrayidx4 = getelementptr inbounds float, ptr %out_b, i64 %iv
147+
store float %extract_b, ptr %arrayidx4, align 4
148+
br label %if.merge
149+
150+
if.merge:
151+
%iv.next = add nuw nsw i64 %iv, 1
152+
%cond = icmp slt i64 %iv.next, 1024
153+
br i1 %cond, label %for.body, label %for.end
154+
155+
for.end:
156+
ret void
157+
}

0 commit comments

Comments
 (0)