Skip to content

Commit 213b849

Browse files
committed
[RISCV][GISel] Use libcalls for some FP instructions when F/D aren't present.
This is based on what fails when adding integer only RUN lines to float-intrinsics.ll and double-intrinsics.ll. We're still missing a lot of test cases that SelectionDAG has. These will be added in future patches.
1 parent c8b837a commit 213b849

File tree

4 files changed

+815
-8
lines changed

4 files changed

+815
-8
lines changed

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,25 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
491491

492492
// FP Operations
493493

494-
getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FMA, G_FNEG,
495-
G_FABS, G_FSQRT, G_FMAXNUM, G_FMINNUM})
494+
getActionDefinitionsBuilder({G_FSUB, G_FDIV, G_FNEG})
496495
.legalFor(ST.hasStdExtF(), {s32})
497496
.legalFor(ST.hasStdExtD(), {s64})
498497
.legalFor(ST.hasStdExtZfh(), {s16});
499498

499+
// FIXME: Merge with FSUB/FDIV/etc when we use libcalls for them.
500+
getActionDefinitionsBuilder(
501+
{G_FADD, G_FMUL, G_FMA, G_FSQRT, G_FMAXNUM, G_FMINNUM})
502+
.legalFor(ST.hasStdExtF(), {s32})
503+
.legalFor(ST.hasStdExtD(), {s64})
504+
.legalFor(ST.hasStdExtZfh(), {s16})
505+
.libcallFor({s32, s64});
506+
507+
getActionDefinitionsBuilder(G_FABS)
508+
.legalFor(ST.hasStdExtF(), {s32})
509+
.legalFor(ST.hasStdExtD(), {s64})
510+
.legalFor(ST.hasStdExtZfh(), {s16})
511+
.lowerFor({s32, s64});
512+
500513
getActionDefinitionsBuilder(G_FREM)
501514
.libcallFor({s32, s64})
502515
.minScalar(0, s32)
@@ -506,7 +519,8 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
506519
.legalFor(ST.hasStdExtF(), {{s32, s32}})
507520
.legalFor(ST.hasStdExtD(), {{s64, s64}, {s32, s64}, {s64, s32}})
508521
.legalFor(ST.hasStdExtZfh(), {{s16, s16}, {s16, s32}, {s32, s16}})
509-
.legalFor(ST.hasStdExtZfh() && ST.hasStdExtD(), {{s16, s64}, {s64, s16}});
522+
.legalFor(ST.hasStdExtZfh() && ST.hasStdExtD(), {{s16, s64}, {s64, s16}})
523+
.lower();
510524

511525
// FIXME: Use Zfhmin.
512526
getActionDefinitionsBuilder(G_FPTRUNC)
@@ -528,7 +542,8 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
528542
getActionDefinitionsBuilder(G_IS_FPCLASS)
529543
.customFor(ST.hasStdExtF(), {{s1, s32}})
530544
.customFor(ST.hasStdExtD(), {{s1, s64}})
531-
.customFor(ST.hasStdExtZfh(), {{s1, s16}});
545+
.customFor(ST.hasStdExtZfh(), {{s1, s16}})
546+
.lowerFor({{s1, s32}, {s1, s64}});
532547

533548
getActionDefinitionsBuilder(G_FCONSTANT)
534549
.legalFor(ST.hasStdExtF(), {s32})

0 commit comments

Comments
 (0)