@@ -423,16 +423,19 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
423
423
.legalIf (typeIsScalarFPArith (0 , ST))
424
424
.lowerFor ({s32, s64});
425
425
426
- getActionDefinitionsBuilder ({G_FPTOSI, G_FPTOUI})
427
- .legalIf (all (typeInSet (0 , {s32, sXLen }), typeIsScalarFPArith (1 , ST)))
428
- .widenScalarToNextPow2 (0 )
429
- .clampScalar (0 , s32, sXLen )
430
- .libcall ();
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 ();
431
432
432
- getActionDefinitionsBuilder ({G_SITOFP, G_UITOFP})
433
- .legalIf (all (typeIsScalarFPArith (0 , ST), typeInSet (1 , {s32, sXLen })))
434
- .widenScalarToNextPow2 (1 )
435
- .clampScalar (1 , s32, sXLen );
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 );
436
439
437
440
// FIXME: We can do custom inline expansion like SelectionDAG.
438
441
// FIXME: Legal with Zfa.
0 commit comments