[PATCH] D130594: [RISCV] Inline ceil/floor/trunc for float and double

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 11:46:38 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, kito-cheng, asb.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

For ceil, floor, and trunc we have existing custom lowering for vectors.  This change extends that custom lowering for the scalar cases.  One slight subtlety with the scalar case is that we must use the full XLEN for the integer type, and that for doubles on riscv32 we can't use this as we can't round trip the full range through integer.

I would appreciate careful review here.  I am by no means a floating point expert.  My reasoning on the correctness of this basically comes down to matching what the vector code already does and the knowledge that rounding modes are shared between scalar and vector so if the existing code gets that right, then presumably so must the scalar version.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130594

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/double-intrinsics.ll
  llvm/test/CodeGen/RISCV/double-round-conv.ll
  llvm/test/CodeGen/RISCV/float-intrinsics.ll
  llvm/test/CodeGen/RISCV/float-round-conv-sat.ll
  llvm/test/CodeGen/RISCV/float-round-conv.ll
  llvm/test/CodeGen/RISCV/half-intrinsics.ll
  llvm/test/CodeGen/RISCV/half-round-conv-sat.ll
  llvm/test/CodeGen/RISCV/half-round-conv.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130594.447779.patch
Type: text/x-patch
Size: 92039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220726/9f3c7352/attachment-0001.bin>


More information about the llvm-commits mailing list