[PATCH] D136916: [LoongArch] Fix codegen for [s/u]itofp instructions

wanglei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 22:56:29 PDT 2022


wangleiat created this revision.
wangleiat added reviewers: SixWeining, xen0n, xry111, gonglingqin, MaskRay.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
wangleiat requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch fixes codegen for `[s/u]itofp` instructions.

In LoongArch, a legal int-to-float conversion is done in two steps:

1, Move the data from `GPR` to `FPR`. (FRLen >= GRLen)
2, Conversion in `FPR`. (the data in `FPR` is treated as a signed

  value)

Based on the above features, when the type's BitWidth meets the
requirements, all `SINT_TO_FP` are legal, all `UINT_TO_FP` are expand
and lowered to libcall when appropriate.
The only special case is, LoongArch64 with `+f,-d` features. At this
point, custom processing is required for `[S/U]INT_TO_FP`. Of course, we
can also ignore it and use libcall directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136916

Files:
  llvm/lib/Target/LoongArch/LoongArchFloat32InstrInfo.td
  llvm/lib/Target/LoongArch/LoongArchFloat64InstrInfo.td
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/test/CodeGen/LoongArch/ir-instruction/double-convert.ll
  llvm/test/CodeGen/LoongArch/ir-instruction/float-convert.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136916.471400.patch
Type: text/x-patch
Size: 12251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/0375f998/attachment.bin>


More information about the llvm-commits mailing list