Skip to content

Commit 3307b03

Browse files
authored
[LV] Teach the loop vectorizer llvm.sincos is trivially vectorizable (#128035)
Depends on #123210
1 parent 4d387c4 commit 3307b03

File tree

7 files changed

+431
-19
lines changed

7 files changed

+431
-19
lines changed

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ bool llvm::isTriviallyVectorizable(Intrinsic::ID ID) {
7272
case Intrinsic::atan2:
7373
case Intrinsic::sin:
7474
case Intrinsic::cos:
75+
case Intrinsic::sincos:
7576
case Intrinsic::tan:
7677
case Intrinsic::sinh:
7778
case Intrinsic::cosh:
@@ -185,6 +186,7 @@ bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(
185186
case Intrinsic::ucmp:
186187
case Intrinsic::scmp:
187188
return OpdIdx == -1 || OpdIdx == 0;
189+
case Intrinsic::sincos:
188190
case Intrinsic::is_fpclass:
189191
case Intrinsic::vp_is_fpclass:
190192
return OpdIdx == 0;

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2926,7 +2926,8 @@ LoopVectorizationCostModel::getVectorIntrinsicCost(CallInst *CI,
29262926
[&](Type *Ty) { return maybeVectorizeType(Ty, VF); });
29272927

29282928
IntrinsicCostAttributes CostAttrs(ID, RetTy, Arguments, ParamTys, FMF,
2929-
dyn_cast<IntrinsicInst>(CI));
2929+
dyn_cast<IntrinsicInst>(CI),
2930+
InstructionCost::getInvalid(), TLI);
29302931
return TTI.getIntrinsicInstrCost(CostAttrs, CostKind);
29312932
}
29322933

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
11851185
FastMathFlags FMF = hasFastMathFlags() ? getFastMathFlags() : FastMathFlags();
11861186
IntrinsicCostAttributes CostAttrs(
11871187
VectorIntrinsicID, RetTy, Arguments, ParamTys, FMF,
1188-
dyn_cast_or_null<IntrinsicInst>(getUnderlyingValue()));
1188+
dyn_cast_or_null<IntrinsicInst>(getUnderlyingValue()),
1189+
InstructionCost::getInvalid(), &Ctx.TLI);
11891190
return Ctx.TTI.getIntrinsicInstrCost(CostAttrs, Ctx.CostKind);
11901191
}
11911192

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --filter "(:|sincos|extractvalue|store)" --version 5
2+
; 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
3+
; 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: FileCheck --input-file=%t.1 --check-prefix=CHECK-COST %s
5+
; RUN: FileCheck --input-file=%t.2 --check-prefix=CHECK-COST-ARMPL %s
6+
; REQUIRES: asserts
7+
8+
; CHECK-COST-LABEL: sincos_f32
9+
; CHECK-COST: LV: Found an estimated cost of 10 for VF 1 For instruction: %call = tail call { float, float } @llvm.sincos.f32(float %in_val)
10+
; CHECK-COST: Cost of 26 for VF 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
11+
; CHECK-COST: Cost of 58 for VF 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
12+
; CHECK-COST: Cost of Invalid for VF vscale x 1: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
13+
; CHECK-COST: Cost of Invalid for VF vscale x 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
14+
; CHECK-COST: Cost of Invalid for VF vscale x 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
15+
16+
; CHECK-COST-ARMPL-LABEL: sincos_f32
17+
; CHECK-COST-ARMPL: LV: Found an estimated cost of 10 for VF 1 For instruction: %call = tail call { float, float } @llvm.sincos.f32(float %in_val)
18+
; CHECK-COST-ARMPL: Cost of 26 for VF 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
19+
; CHECK-COST-ARMPL: Cost of 12 for VF 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
20+
; CHECK-COST-ARMPL: Cost of Invalid for VF vscale x 1: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
21+
; CHECK-COST-ARMPL: Cost of Invalid for VF vscale x 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
22+
; CHECK-COST-ARMPL: Cost of 13 for VF vscale x 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
23+
24+
define void @sincos_f32(ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) {
25+
; CHECK-LABEL: define void @sincos_f32(
26+
; CHECK-SAME: ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) #[[ATTR0:[0-9]+]] {
27+
; CHECK: [[ENTRY:.*:]]
28+
; CHECK: [[VECTOR_PH:.*:]]
29+
; CHECK: [[VECTOR_BODY:.*:]]
30+
; CHECK: [[TMP3:%.*]] = call { <2 x float>, <2 x float> } @llvm.sincos.v2f32(<2 x float> [[WIDE_LOAD:%.*]])
31+
; CHECK: [[TMP4:%.*]] = extractvalue { <2 x float>, <2 x float> } [[TMP3]], 0
32+
; CHECK: [[TMP5:%.*]] = extractvalue { <2 x float>, <2 x float> } [[TMP3]], 1
33+
; CHECK: store <2 x float> [[TMP4]], ptr [[TMP7:%.*]], align 4
34+
; CHECK: store <2 x float> [[TMP5]], ptr [[TMP9:%.*]], align 4
35+
; CHECK: [[MIDDLE_BLOCK:.*:]]
36+
; CHECK: [[SCALAR_PH:.*:]]
37+
; CHECK: [[FOR_BODY:.*:]]
38+
; CHECK: [[CALL:%.*]] = tail call { float, float } @llvm.sincos.f32(float [[IN_VAL:%.*]])
39+
; CHECK: [[EXTRACT_A:%.*]] = extractvalue { float, float } [[CALL]], 0
40+
; CHECK: [[EXTRACT_B:%.*]] = extractvalue { float, float } [[CALL]], 1
41+
; CHECK: store float [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 4
42+
; CHECK: store float [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 4
43+
; CHECK: [[EXIT:.*:]]
44+
;
45+
; CHECK-ARMPL-LABEL: define void @sincos_f32(
46+
; CHECK-ARMPL-SAME: ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) #[[ATTR0:[0-9]+]] {
47+
; CHECK-ARMPL: [[ENTRY:.*:]]
48+
; CHECK-ARMPL: [[VECTOR_PH:.*:]]
49+
; CHECK-ARMPL: [[VECTOR_BODY:.*:]]
50+
; CHECK-ARMPL: [[TMP12:%.*]] = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.sincos.nxv4f32(<vscale x 4 x float> [[WIDE_LOAD:%.*]])
51+
; CHECK-ARMPL: [[TMP13:%.*]] = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.sincos.nxv4f32(<vscale x 4 x float> [[WIDE_LOAD1:%.*]])
52+
; CHECK-ARMPL: [[TMP14:%.*]] = extractvalue { <vscale x 4 x float>, <vscale x 4 x float> } [[TMP12]], 0
53+
; CHECK-ARMPL: [[TMP15:%.*]] = extractvalue { <vscale x 4 x float>, <vscale x 4 x float> } [[TMP13]], 0
54+
; CHECK-ARMPL: [[TMP16:%.*]] = extractvalue { <vscale x 4 x float>, <vscale x 4 x float> } [[TMP12]], 1
55+
; CHECK-ARMPL: [[TMP17:%.*]] = extractvalue { <vscale x 4 x float>, <vscale x 4 x float> } [[TMP13]], 1
56+
; CHECK-ARMPL: store <vscale x 4 x float> [[TMP14]], ptr [[TMP19:%.*]], align 4
57+
; CHECK-ARMPL: store <vscale x 4 x float> [[TMP15]], ptr [[TMP22:%.*]], align 4
58+
; CHECK-ARMPL: store <vscale x 4 x float> [[TMP16]], ptr [[TMP24:%.*]], align 4
59+
; CHECK-ARMPL: store <vscale x 4 x float> [[TMP17]], ptr [[TMP27:%.*]], align 4
60+
; CHECK-ARMPL: [[MIDDLE_BLOCK:.*:]]
61+
; CHECK-ARMPL: [[SCALAR_PH:.*:]]
62+
; CHECK-ARMPL: [[FOR_BODY:.*:]]
63+
; CHECK-ARMPL: [[CALL:%.*]] = tail call { float, float } @llvm.sincos.f32(float [[IN_VAL:%.*]])
64+
; CHECK-ARMPL: [[EXTRACT_A:%.*]] = extractvalue { float, float } [[CALL]], 0
65+
; CHECK-ARMPL: [[EXTRACT_B:%.*]] = extractvalue { float, float } [[CALL]], 1
66+
; CHECK-ARMPL: store float [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 4
67+
; CHECK-ARMPL: store float [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 4
68+
; CHECK-ARMPL: [[EXIT:.*:]]
69+
;
70+
entry:
71+
br label %for.body
72+
73+
for.body:
74+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
75+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %iv
76+
%in_val = load float, ptr %arrayidx, align 4
77+
%call = tail call { float, float } @llvm.sincos.f32(float %in_val)
78+
%extract_a = extractvalue { float, float } %call, 0
79+
%extract_b = extractvalue { float, float } %call, 1
80+
%arrayidx2 = getelementptr inbounds float, ptr %out_a, i64 %iv
81+
store float %extract_a, ptr %arrayidx2, align 4
82+
%arrayidx4 = getelementptr inbounds float, ptr %out_b, i64 %iv
83+
store float %extract_b, ptr %arrayidx4, align 4
84+
%iv.next = add nuw nsw i64 %iv, 1
85+
%exitcond.not = icmp eq i64 %iv.next, 1024
86+
br i1 %exitcond.not, label %exit, label %for.body
87+
88+
exit:
89+
ret void
90+
}
91+
92+
; CHECK-COST-LABEL: sincos_f64
93+
; CHECK-COST: LV: Found an estimated cost of 10 for VF 1 For instruction: %call = tail call { double, double } @llvm.sincos.f64(double %in_val)
94+
; CHECK-COST: Cost of 26 for VF 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
95+
; CHECK-COST: Cost of Invalid for VF vscale x 1: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
96+
; CHECK-COST: Cost of Invalid for VF vscale x 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
97+
98+
; CHECK-COST-ARMPL-LABEL: sincos_f64
99+
; CHECK-COST-ARMPL: LV: Found an estimated cost of 10 for VF 1 For instruction: %call = tail call { double, double } @llvm.sincos.f64(double %in_val)
100+
; CHECK-COST-ARMPL: Cost of 12 for VF 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
101+
; CHECK-COST-ARMPL: Cost of Invalid for VF vscale x 1: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
102+
; CHECK-COST-ARMPL: Cost of 13 for VF vscale x 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
103+
104+
define void @sincos_f64(ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) {
105+
; CHECK-LABEL: define void @sincos_f64(
106+
; CHECK-SAME: ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) #[[ATTR0]] {
107+
; CHECK: [[ENTRY:.*:]]
108+
; CHECK: [[VECTOR_PH:.*:]]
109+
; CHECK: [[VECTOR_BODY:.*:]]
110+
; CHECK: [[TMP3:%.*]] = call { <2 x double>, <2 x double> } @llvm.sincos.v2f64(<2 x double> [[WIDE_LOAD:%.*]])
111+
; CHECK: [[TMP4:%.*]] = extractvalue { <2 x double>, <2 x double> } [[TMP3]], 0
112+
; CHECK: [[TMP5:%.*]] = extractvalue { <2 x double>, <2 x double> } [[TMP3]], 1
113+
; CHECK: store <2 x double> [[TMP4]], ptr [[TMP7:%.*]], align 8
114+
; CHECK: store <2 x double> [[TMP5]], ptr [[TMP9:%.*]], align 8
115+
; CHECK: [[MIDDLE_BLOCK:.*:]]
116+
; CHECK: [[SCALAR_PH:.*:]]
117+
; CHECK: [[FOR_BODY:.*:]]
118+
; CHECK: [[CALL:%.*]] = tail call { double, double } @llvm.sincos.f64(double [[IN_VAL:%.*]])
119+
; CHECK: [[EXTRACT_A:%.*]] = extractvalue { double, double } [[CALL]], 0
120+
; CHECK: [[EXTRACT_B:%.*]] = extractvalue { double, double } [[CALL]], 1
121+
; CHECK: store double [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 8
122+
; CHECK: store double [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 8
123+
; CHECK: [[EXIT:.*:]]
124+
;
125+
; CHECK-ARMPL-LABEL: define void @sincos_f64(
126+
; CHECK-ARMPL-SAME: ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) #[[ATTR0]] {
127+
; CHECK-ARMPL: [[ENTRY:.*:]]
128+
; CHECK-ARMPL: [[VECTOR_PH:.*:]]
129+
; CHECK-ARMPL: [[VECTOR_BODY:.*:]]
130+
; CHECK-ARMPL: [[TMP12:%.*]] = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.sincos.nxv2f64(<vscale x 2 x double> [[WIDE_LOAD:%.*]])
131+
; CHECK-ARMPL: [[TMP13:%.*]] = call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.sincos.nxv2f64(<vscale x 2 x double> [[WIDE_LOAD1:%.*]])
132+
; CHECK-ARMPL: [[TMP14:%.*]] = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } [[TMP12]], 0
133+
; CHECK-ARMPL: [[TMP15:%.*]] = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } [[TMP13]], 0
134+
; CHECK-ARMPL: [[TMP16:%.*]] = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } [[TMP12]], 1
135+
; CHECK-ARMPL: [[TMP17:%.*]] = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } [[TMP13]], 1
136+
; CHECK-ARMPL: store <vscale x 2 x double> [[TMP14]], ptr [[TMP19:%.*]], align 8
137+
; CHECK-ARMPL: store <vscale x 2 x double> [[TMP15]], ptr [[TMP22:%.*]], align 8
138+
; CHECK-ARMPL: store <vscale x 2 x double> [[TMP16]], ptr [[TMP24:%.*]], align 8
139+
; CHECK-ARMPL: store <vscale x 2 x double> [[TMP17]], ptr [[TMP27:%.*]], align 8
140+
; CHECK-ARMPL: [[MIDDLE_BLOCK:.*:]]
141+
; CHECK-ARMPL: [[SCALAR_PH:.*:]]
142+
; CHECK-ARMPL: [[FOR_BODY:.*:]]
143+
; CHECK-ARMPL: [[CALL:%.*]] = tail call { double, double } @llvm.sincos.f64(double [[IN_VAL:%.*]])
144+
; CHECK-ARMPL: [[EXTRACT_A:%.*]] = extractvalue { double, double } [[CALL]], 0
145+
; CHECK-ARMPL: [[EXTRACT_B:%.*]] = extractvalue { double, double } [[CALL]], 1
146+
; CHECK-ARMPL: store double [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 8
147+
; CHECK-ARMPL: store double [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 8
148+
; CHECK-ARMPL: [[EXIT:.*:]]
149+
;
150+
entry:
151+
br label %for.body
152+
153+
for.body:
154+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
155+
%arrayidx = getelementptr inbounds double, ptr %in, i64 %iv
156+
%in_val = load double, ptr %arrayidx, align 8
157+
%call = tail call { double, double } @llvm.sincos.f64(double %in_val)
158+
%extract_a = extractvalue { double, double } %call, 0
159+
%extract_b = extractvalue { double, double } %call, 1
160+
%arrayidx2 = getelementptr inbounds double, ptr %out_a, i64 %iv
161+
store double %extract_a, ptr %arrayidx2, align 8
162+
%arrayidx4 = getelementptr inbounds double, ptr %out_b, i64 %iv
163+
store double %extract_b, ptr %arrayidx4, align 8
164+
%iv.next = add nuw nsw i64 %iv, 1
165+
%exitcond.not = icmp eq i64 %iv.next, 1024
166+
br i1 %exitcond.not, label %exit, label %for.body
167+
168+
exit:
169+
ret void
170+
}
171+
172+
; CHECK-COST-LABEL: predicated_sincos
173+
; CHECK-COST: LV: Found an estimated cost of 10 for VF 1 For instruction: %call = tail call { float, float } @llvm.sincos.f32(float %in_val)
174+
; CHECK-COST: Cost of 26 for VF 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
175+
; CHECK-COST: Cost of 58 for VF 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
176+
; CHECK-COST: Cost of Invalid for VF vscale x 1: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
177+
; CHECK-COST: Cost of Invalid for VF vscale x 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
178+
; CHECK-COST: Cost of Invalid for VF vscale x 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
179+
180+
; CHECK-COST-ARMPL-LABEL: predicated_sincos
181+
; CHECK-COST-ARMPL: LV: Found an estimated cost of 10 for VF 1 For instruction: %call = tail call { float, float } @llvm.sincos.f32(float %in_val)
182+
; CHECK-COST-ARMPL: Cost of 26 for VF 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
183+
; CHECK-COST-ARMPL: Cost of 12 for VF 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
184+
; CHECK-COST-ARMPL: Cost of Invalid for VF vscale x 1: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
185+
; CHECK-COST-ARMPL: Cost of Invalid for VF vscale x 2: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
186+
; CHECK-COST-ARMPL: Cost of 13 for VF vscale x 4: WIDEN-INTRINSIC ir<%call> = call llvm.sincos(ir<%in_val>)
187+
188+
define void @predicated_sincos(float %x, ptr noalias %in, ptr noalias writeonly %out_a, ptr noalias writeonly %out_b) {
189+
; CHECK-LABEL: define void @predicated_sincos(
190+
; CHECK-SAME: float [[X:%.*]], ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) #[[ATTR0]] {
191+
; CHECK: [[ENTRY:.*:]]
192+
; CHECK: [[FOR_BODY:.*:]]
193+
; CHECK: [[IF_THEN:.*:]]
194+
; CHECK: [[CALL:%.*]] = tail call { float, float } @llvm.sincos.f32(float [[IN_VAL:%.*]])
195+
; CHECK: [[EXTRACT_A:%.*]] = extractvalue { float, float } [[CALL]], 0
196+
; CHECK: [[EXTRACT_B:%.*]] = extractvalue { float, float } [[CALL]], 1
197+
; CHECK: store float [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 4
198+
; CHECK: store float [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 4
199+
; CHECK: [[IF_MERGE:.*:]]
200+
; CHECK: [[FOR_END:.*:]]
201+
;
202+
; CHECK-ARMPL-LABEL: define void @predicated_sincos(
203+
; CHECK-ARMPL-SAME: float [[X:%.*]], ptr noalias [[IN:%.*]], ptr noalias writeonly [[OUT_A:%.*]], ptr noalias writeonly [[OUT_B:%.*]]) #[[ATTR0]] {
204+
; CHECK-ARMPL: [[ENTRY:.*:]]
205+
; CHECK-ARMPL: [[VECTOR_PH:.*:]]
206+
; CHECK-ARMPL: [[VECTOR_BODY:.*:]]
207+
; CHECK-ARMPL: [[TMP15:%.*]] = call { <vscale x 4 x float>, <vscale x 4 x float> } @llvm.sincos.nxv4f32(<vscale x 4 x float> [[WIDE_MASKED_LOAD:%.*]])
208+
; CHECK-ARMPL: [[TMP16:%.*]] = extractvalue { <vscale x 4 x float>, <vscale x 4 x float> } [[TMP15]], 0
209+
; CHECK-ARMPL: [[TMP17:%.*]] = extractvalue { <vscale x 4 x float>, <vscale x 4 x float> } [[TMP15]], 1
210+
; CHECK-ARMPL: call void @llvm.masked.store.nxv4f32.p0(<vscale x 4 x float> [[TMP16]], ptr [[TMP19:%.*]], i32 4, <vscale x 4 x i1> [[TMP14:%.*]])
211+
; CHECK-ARMPL: call void @llvm.masked.store.nxv4f32.p0(<vscale x 4 x float> [[TMP17]], ptr [[TMP21:%.*]], i32 4, <vscale x 4 x i1> [[TMP14]])
212+
; CHECK-ARMPL: [[MIDDLE_BLOCK:.*:]]
213+
; CHECK-ARMPL: [[SCALAR_PH:.*:]]
214+
; CHECK-ARMPL: [[FOR_BODY:.*:]]
215+
; CHECK-ARMPL: [[IF_THEN:.*:]]
216+
; CHECK-ARMPL: [[CALL:%.*]] = tail call { float, float } @llvm.sincos.f32(float [[IN_VAL:%.*]])
217+
; CHECK-ARMPL: [[EXTRACT_A:%.*]] = extractvalue { float, float } [[CALL]], 0
218+
; CHECK-ARMPL: [[EXTRACT_B:%.*]] = extractvalue { float, float } [[CALL]], 1
219+
; CHECK-ARMPL: store float [[EXTRACT_A]], ptr [[ARRAYIDX2:%.*]], align 4
220+
; CHECK-ARMPL: store float [[EXTRACT_B]], ptr [[ARRAYIDX4:%.*]], align 4
221+
; CHECK-ARMPL: [[IF_MERGE:.*:]]
222+
; CHECK-ARMPL: [[FOR_END:.*:]]
223+
;
224+
entry:
225+
br label %for.body
226+
227+
for.body:
228+
%iv = phi i64 [ %iv.next, %if.merge ], [ 0, %entry ]
229+
%arrayidx = getelementptr inbounds float, ptr %in, i64 %iv
230+
%in_val = load float, ptr %arrayidx, align 4
231+
%if_cond = fcmp olt float %in_val, %x
232+
br i1 %if_cond, label %if.then, label %if.merge
233+
234+
if.then:
235+
%call = tail call { float, float } @llvm.sincos.f32(float %in_val)
236+
%extract_a = extractvalue { float, float } %call, 0
237+
%extract_b = extractvalue { float, float } %call, 1
238+
%arrayidx2 = getelementptr inbounds float, ptr %out_a, i64 %iv
239+
store float %extract_a, ptr %arrayidx2, align 4
240+
%arrayidx4 = getelementptr inbounds float, ptr %out_b, i64 %iv
241+
store float %extract_b, ptr %arrayidx4, align 4
242+
br label %if.merge
243+
244+
if.merge:
245+
%iv.next = add nuw nsw i64 %iv, 1
246+
%cond = icmp slt i64 %iv.next, 1024
247+
br i1 %cond, label %for.body, label %for.end
248+
249+
for.end:
250+
ret void
251+
}

0 commit comments

Comments
 (0)