This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add rvv codegen support for vp.fptrunc.
ClosedPublic

Authored by jacquesguan on Apr 15 2022, 12:42 AM.

Details

Summary

This patch adds rvv codegen support for vp.fptrunc. The lowering of fp_round and vp.fptrunc share most code so use a common lowering function to handle those two, similar to vp.trunc.

Diff Detail

Event Timeline

jacquesguan created this revision.Apr 15 2022, 12:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 12:42 AM
jacquesguan requested review of this revision.Apr 15 2022, 12:42 AM

The incongruousness of lowering vp.fptrunc to VP_FPTRUNC but calling a "RoundLike" function was a bit confusing. I opened D123847 to try and make them more consistent.

frasercrmck added inline comments.Apr 15 2022, 1:54 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4438

We're returning here after already creating the VL ops. Ideally we'd only create nodes once we know we're going to commit to returning something. This is a smaller issue in the original code but I don't think it needs to be like this. The early-exit check isn't dependent on any previous computations.

address comment.

jacquesguan added inline comments.Apr 15 2022, 2:32 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4438

Done, I moved it to the begin of the function.

craig.topper added inline comments.Apr 15 2022, 3:13 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
3284

This check wasn't in the original code. Why is it needed now?

jacquesguan added inline comments.Apr 17 2022, 1:22 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
3284

There is a branch that will just return Op when Op is not a vector in the original code.

if (!VT.isVector() || VT.getVectorElementType() != MVT::f16 ||
        SrcVT.getVectorElementType() != MVT::f64) {
      // For scalable vectors, we only need to close the gap between
      // vXf64<->vXf16.
      if (!VT.isFixedLengthVector())
        return Op;

...

}

These two ifs contain the no vector type situation, I split it out because this new lowering function only focus the vector FP round.

This revision is now accepted and ready to land.Apr 18 2022, 1:00 PM
This revision was landed with ongoing or failed builds.Apr 18 2022, 7:31 PM
This revision was automatically updated to reflect the committed changes.