aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2024-06-26 09:53:37 -0700
committerGitHub <noreply@github.com>2024-06-26 09:53:37 -0700
commit581fd2fa573e39607ea164c0b4a8057baeb62c69 (patch)
treed8af50649388e78e081085af681d40e0ad714640 /llvm/lib
parent7c4fc9ccc058137877c99bad402a91d3ce640bbb (diff)
downloadllvm-581fd2fa573e39607ea164c0b4a8057baeb62c69.zip
llvm-581fd2fa573e39607ea164c0b4a8057baeb62c69.tar.gz
llvm-581fd2fa573e39607ea164c0b4a8057baeb62c69.tar.bz2
[RISCV][GISel] Support fptoi and itofp for Zfh. (#96707)
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index f6761ce..4ce1828 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -423,16 +423,19 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
FConstantActions.legalFor({s16});
FConstantActions.lowerFor({s32, s64});
- getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
- .legalIf(all(typeInSet(0, {s32, sXLen}), typeIsScalarFPArith(1, ST)))
- .widenScalarToNextPow2(0)
- .clampScalar(0, s32, sXLen)
- .libcall();
+ auto &FPToIActions =
+ getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
+ .legalIf(all(typeInSet(0, {s32, sXLen}), typeIsScalarFPArith(1, ST)));
+ if (ST.hasStdExtZfh())
+ FPToIActions.legalFor({{s32, s16}, {sXLen, s16}});
+ FPToIActions.widenScalarToNextPow2(0).clampScalar(0, s32, sXLen).libcall();
- getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
- .legalIf(all(typeIsScalarFPArith(0, ST), typeInSet(1, {s32, sXLen})))
- .widenScalarToNextPow2(1)
- .clampScalar(1, s32, sXLen);
+ auto &IToFPActions =
+ getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
+ .legalIf(all(typeIsScalarFPArith(0, ST), typeInSet(1, {s32, sXLen})));
+ if (ST.hasStdExtZfh())
+ IToFPActions.legalFor({{s16, s32}, {s16, sXLen}});
+ IToFPActions.widenScalarToNextPow2(1).clampScalar(1, s32, sXLen);
// FIXME: We can do custom inline expansion like SelectionDAG.
// FIXME: Legal with Zfa.