Skip to content

Commit e15d28d

Browse files
toppercarsenm
authored andcommitted
[RISCV] Add Zfh to typeIsScalarFPArith and simplify code. NFC
Now that we have Zfh supported and tested for every opcode that uses typeIsScalarFPArith, we can fold Zfh into it.
1 parent 116db1f commit e15d28d

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

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

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -404,38 +404,28 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
404404
typeIs(1, s16)(Query));
405405
});
406406

407-
auto &FCmpActions = getActionDefinitionsBuilder(G_FCMP).legalIf(
408-
all(typeIs(0, sXLen), typeIsScalarFPArith(1, ST)));
409-
// TODO: Fold this into typeIsScalarFPArith.
410-
if (ST.hasStdExtZfh())
411-
FCmpActions.legalFor({sXLen, s16});
412-
FCmpActions.clampScalar(0, sXLen, sXLen);
407+
getActionDefinitionsBuilder(G_FCMP)
408+
.legalIf(all(typeIs(0, sXLen), typeIsScalarFPArith(1, ST)))
409+
.clampScalar(0, sXLen, sXLen);
413410

414411
// TODO: Support vector version of G_IS_FPCLASS.
415-
auto &FClassActions =
416-
getActionDefinitionsBuilder(G_IS_FPCLASS)
417-
.customIf(all(typeIs(0, s1), typeIsScalarFPArith(1, ST)));
418-
// TODO: Fold this into typeIsScalarFPArith.
419-
if (ST.hasStdExtZfh())
420-
FClassActions.customFor({s1, s16});
412+
getActionDefinitionsBuilder(G_IS_FPCLASS)
413+
.customIf(all(typeIs(0, s1), typeIsScalarFPArith(1, ST)));
421414

422415
getActionDefinitionsBuilder(G_FCONSTANT)
423416
.legalIf(typeIsScalarFPArith(0, ST))
424417
.lowerFor({s32, s64});
425418

426-
auto &FPToIActions =
427-
getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
428-
.legalIf(all(typeInSet(0, {s32, sXLen}), typeIsScalarFPArith(1, ST)));
429-
if (ST.hasStdExtZfh())
430-
FPToIActions.legalFor({{s32, s16}, {sXLen, s16}});
431-
FPToIActions.widenScalarToNextPow2(0).clampScalar(0, s32, sXLen).libcall();
432-
433-
auto &IToFPActions =
434-
getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
435-
.legalIf(all(typeIsScalarFPArith(0, ST), typeInSet(1, {s32, sXLen})));
436-
if (ST.hasStdExtZfh())
437-
IToFPActions.legalFor({{s16, s32}, {s16, sXLen}});
438-
IToFPActions.widenScalarToNextPow2(1).clampScalar(1, s32, sXLen);
419+
getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
420+
.legalIf(all(typeInSet(0, {s32, sXLen}), typeIsScalarFPArith(1, ST)))
421+
.widenScalarToNextPow2(0)
422+
.clampScalar(0, s32, sXLen)
423+
.libcall();
424+
425+
getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
426+
.legalIf(all(typeIsScalarFPArith(0, ST), typeInSet(1, {s32, sXLen})))
427+
.widenScalarToNextPow2(1)
428+
.clampScalar(1, s32, sXLen);
439429

440430
// FIXME: We can do custom inline expansion like SelectionDAG.
441431
// FIXME: Legal with Zfa.

0 commit comments

Comments
 (0)