Skip to content

Commit cccc09d

Browse files
committed
[SDAG] Add missing ppc_fp128 ExpandFloatRes for sincos[pi]
1 parent 72768d9 commit cccc09d

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,8 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
15701570
case ISD::STRICT_FREM:
15711571
case ISD::FREM: ExpandFloatRes_FREM(N, Lo, Hi); break;
15721572
case ISD::FMODF: ExpandFloatRes_FMODF(N); break;
1573+
case ISD::FSINCOS: ExpandFloatRes_FSINCOS(N); break;
1574+
case ISD::FSINCOSPI: ExpandFloatRes_FSINCOSPI(N); break;
15731575
// clang-format on
15741576
}
15751577

@@ -1625,6 +1627,15 @@ void DAGTypeLegalizer::ExpandFloatRes_FMODF(SDNode *N) {
16251627
/*CallRetResNo=*/0);
16261628
}
16271629

1630+
void DAGTypeLegalizer::ExpandFloatRes_FSINCOS(SDNode *N) {
1631+
ExpandFloatRes_UnaryWithTwoFPResults(N, RTLIB::getSINCOS(N->getValueType(0)));
1632+
}
1633+
1634+
void DAGTypeLegalizer::ExpandFloatRes_FSINCOSPI(SDNode *N) {
1635+
ExpandFloatRes_UnaryWithTwoFPResults(N,
1636+
RTLIB::getSINCOSPI(N->getValueType(0)));
1637+
}
1638+
16281639
void DAGTypeLegalizer::ExpandFloatRes_UnaryWithTwoFPResults(
16291640
SDNode *N, RTLIB::Libcall LC, std::optional<unsigned> CallRetResNo) {
16301641
assert(!N->isStrictFPOpcode() && "strictfp not implemented");

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
718718
void ExpandFloatRes_LOAD (SDNode *N, SDValue &Lo, SDValue &Hi);
719719
void ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, SDValue &Hi);
720720
void ExpandFloatRes_FMODF(SDNode *N);
721+
void ExpandFloatRes_FSINCOS(SDNode* N);
722+
void ExpandFloatRes_FSINCOSPI(SDNode* N);
721723
// clang-format on
722724

723725
// Float Operand Expansion.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2+
; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-gnu-linux \
3+
; RUN: -ppc-vsr-nums-as-vr -ppc-asm-full-reg-names < %s | FileCheck %s
4+
5+
define { ppc_fp128, ppc_fp128 } @test_sincos_ppcf128(ppc_fp128 %a) {
6+
; CHECK-LABEL: test_sincos_ppcf128:
7+
; CHECK: # %bb.0:
8+
; CHECK-NEXT: mflr r0
9+
; CHECK-NEXT: stdu r1, -64(r1)
10+
; CHECK-NEXT: std r0, 80(r1)
11+
; CHECK-NEXT: .cfi_def_cfa_offset 64
12+
; CHECK-NEXT: .cfi_offset lr, 16
13+
; CHECK-NEXT: addi r5, r1, 48
14+
; CHECK-NEXT: addi r6, r1, 32
15+
; CHECK-NEXT: bl sincosl
16+
; CHECK-NEXT: nop
17+
; CHECK-NEXT: lfd f1, 48(r1)
18+
; CHECK-NEXT: lfd f2, 56(r1)
19+
; CHECK-NEXT: lfd f3, 32(r1)
20+
; CHECK-NEXT: lfd f4, 40(r1)
21+
; CHECK-NEXT: addi r1, r1, 64
22+
; CHECK-NEXT: ld r0, 16(r1)
23+
; CHECK-NEXT: mtlr r0
24+
; CHECK-NEXT: blr
25+
%result = call { ppc_fp128, ppc_fp128 } @llvm.sincos.ppcf128(ppc_fp128 %a)
26+
ret { ppc_fp128, ppc_fp128 } %result
27+
}
28+
29+
define { ppc_fp128, ppc_fp128 } @test_sincospi_ppcf128(ppc_fp128 %a) {
30+
; CHECK-LABEL: test_sincospi_ppcf128:
31+
; CHECK: # %bb.0:
32+
; CHECK-NEXT: mflr r0
33+
; CHECK-NEXT: stdu r1, -64(r1)
34+
; CHECK-NEXT: std r0, 80(r1)
35+
; CHECK-NEXT: .cfi_def_cfa_offset 64
36+
; CHECK-NEXT: .cfi_offset lr, 16
37+
; CHECK-NEXT: addi r5, r1, 48
38+
; CHECK-NEXT: addi r6, r1, 32
39+
; CHECK-NEXT: bl sincospil
40+
; CHECK-NEXT: nop
41+
; CHECK-NEXT: lfd f1, 48(r1)
42+
; CHECK-NEXT: lfd f2, 56(r1)
43+
; CHECK-NEXT: lfd f3, 32(r1)
44+
; CHECK-NEXT: lfd f4, 40(r1)
45+
; CHECK-NEXT: addi r1, r1, 64
46+
; CHECK-NEXT: ld r0, 16(r1)
47+
; CHECK-NEXT: mtlr r0
48+
; CHECK-NEXT: blr
49+
%result = call { ppc_fp128, ppc_fp128 } @llvm.sincospi.ppcf128(ppc_fp128 %a)
50+
ret { ppc_fp128, ppc_fp128 } %result
51+
}

0 commit comments

Comments
 (0)