[PATCH] D78905: [RISCV] Tests for indirect float conversion

Sam Elliott via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 02:38:28 PDT 2020


lenary created this revision.
lenary added a reviewer: luismarques.
Herald added subscribers: llvm-commits, evandro, apazos, sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: LLVM.
lenary added a child revision: D78906: [RISCV] Add patterns for indirect float conversions.

I worked on some patterns to address the code generated by these
examples, which came out of some differential testing against GCC. The patterns
will be in a follow-up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78905

Files:
  llvm/test/CodeGen/RISCV/double-convert-indirect.ll


Index: llvm/test/CodeGen/RISCV/double-convert-indirect.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/double-convert-indirect.ll
@@ -0,0 +1,50 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+f,+d -verify-machineinstrs < %s \
+; RUN:   | FileCheck -check-prefix=RV32IFD %s
+; RUN: llc -mtriple=riscv64 -mattr=+f,+d -verify-machineinstrs < %s \
+; RUN:   | FileCheck -check-prefix=RV64IFD %s
+
+;; These testcases check that we merge sequences of `fcvt.d.wu; fcvt.s.d` into
+;; `fcvt.s.wu`.
+;;
+;; TODO: Unfortunately, though this only uses 32-bit FP instructions, we cannot
+;; do this optimisation without the D extension as we need 64-bit FP values to
+;; be legal to get the right operands to match.
+
+define float @fcvt_s_w_via_d(i32 %0) nounwind {
+; RV32IFD-LABEL: fcvt_s_w_via_d:
+; RV32IFD:       # %bb.0:
+; RV32IFD-NEXT:    fcvt.d.w ft0, a0
+; RV32IFD-NEXT:    fcvt.s.d ft0, ft0
+; RV32IFD-NEXT:    fmv.x.w a0, ft0
+; RV32IFD-NEXT:    ret
+;
+; RV64IFD-LABEL: fcvt_s_w_via_d:
+; RV64IFD:       # %bb.0:
+; RV64IFD-NEXT:    fcvt.d.w ft0, a0
+; RV64IFD-NEXT:    fcvt.s.d ft0, ft0
+; RV64IFD-NEXT:    fmv.x.w a0, ft0
+; RV64IFD-NEXT:    ret
+  %2 = sitofp i32 %0 to double
+  %3 = fptrunc double %2 to float
+  ret float %3
+}
+
+define float @fcvt_s_wu_via_d(i32 %0) nounwind {
+; RV32IFD-LABEL: fcvt_s_wu_via_d:
+; RV32IFD:       # %bb.0:
+; RV32IFD-NEXT:    fcvt.d.wu ft0, a0
+; RV32IFD-NEXT:    fcvt.s.d ft0, ft0
+; RV32IFD-NEXT:    fmv.x.w a0, ft0
+; RV32IFD-NEXT:    ret
+;
+; RV64IFD-LABEL: fcvt_s_wu_via_d:
+; RV64IFD:       # %bb.0:
+; RV64IFD-NEXT:    fcvt.d.wu ft0, a0
+; RV64IFD-NEXT:    fcvt.s.d ft0, ft0
+; RV64IFD-NEXT:    fmv.x.w a0, ft0
+; RV64IFD-NEXT:    ret
+  %2 = uitofp i32 %0 to double
+  %3 = fptrunc double %2 to float
+  ret float %3
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78905.260245.patch
Type: text/x-patch
Size: 1909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/7c9b8c6f/attachment.bin>


More information about the llvm-commits mailing list