This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Implement support for bf16 truncate/extend on hard FP targets
ClosedPublic

Authored by asb on May 29 2023, 1:38 PM.

Details

Summary

For the same reasons as D151284, this requires custom lowering of the truncate libcall on hard float ABIs (the normal libcall code path is used on soft ABIs).

The extend operation is implemented by a shift just as in the standard legalisation, but needs to be custom lowered because i32 isn't a legal type on RV64.

This patch aims to make the minimal changes that result in correct codegen for the bfloat.ll tests.

Diff Detail

Event Timeline

asb created this revision.May 29 2023, 1:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2023, 1:38 PM
asb requested review of this revision.May 29 2023, 1:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2023, 1:38 PM
craig.topper added inline comments.May 30 2023, 4:22 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4952

I think XLenVT here here should be Op.getOperand(0).getValueType() which probably is XLenVT, but it looks better to use the same VT for both.

joshua-arch1 added a comment.EditedJun 4 2023, 10:54 PM

Are you still working on this patch? I have implemented a similar one early in May 24th.
https://reviews.llvm.org/D151313

This comment was removed by joshua-arch1.
asb updated this revision to Diff 531328.Jun 14 2023, 7:45 AM
asb marked an inline comment as done.

Address review comments, rebase.

@joshua-arch1: I'm sorry our work in this area has overlapped - as I mentioned in the first version of your patch, I was already working on a series in this area and the original form of D151313 was quite different to how it ended up.

This revision is now accepted and ready to land.Jun 16 2023, 2:29 PM