Skip to content

[GISel][RISCV] Anyextend before copying f16 -> i32/i64 #94993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,14 @@ struct RISCVOutgoingValueHandler : public CallLowering::OutgoingValueHandler {

void assignValueToReg(Register ValVReg, Register PhysReg,
const CCValAssign &VA) override {
// If we're passing an f32 value into an i64, anyextend before copying.
if (VA.getLocVT() == MVT::i64 && VA.getValVT() == MVT::f32)
ValVReg = MIRBuilder.buildAnyExt(LLT::scalar(64), ValVReg).getReg(0);
// If we're passing a smaller fp value into a larger integer register,
// anyextend before copying.
if ((VA.getLocVT() == MVT::i64 && VA.getValVT() == MVT::f32) ||
((VA.getLocVT() == MVT::i32 || VA.getLocVT() == MVT::i64) &&
VA.getValVT() == MVT::f16)) {
LLT DstTy = LLT::scalar(VA.getLocVT().getSizeInBits());
ValVReg = MIRBuilder.buildAnyExt(DstTy, ValVReg).getReg(0);
}

Register ExtReg = extendRegister(ValVReg, VA);
MIRBuilder.buildCopy(PhysReg, ExtReg);
Expand Down
Loading
Loading