[PATCH] D111976: [DAG] Create fptosi.sat from clamped fptosi

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 18 01:21:16 PDT 2021


dmgreen created this revision.
dmgreen added reviewers: spatel, RKSimon, craig.topper, tlively, efriedma.
Herald added subscribers: armkevincheng, jsmolens, eric-k256, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, steven.zhang, pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls, jgravelle-google, sbc100, dschuff.
Herald added a reviewer: sjarus.
dmgreen requested review of this revision.
Herald added subscribers: MaskRay, aheejin.
Herald added a project: LLVM.

This adds a fold in DAGCombine to create fptosi_sat from sequences for smin(smax(fptosi(x))) nodes, where the min/max saturate the output of the fp convert to a specific bitwidth (say INT_MIN and INT_MAX). Because it is dealing with smin(/smax) in DAG they may currently be ISD::SMIN, ISD::SETCC/ISD::SELECT, ISD::VSELECT or ISD::SELECT_CC nodes which need to be handled similarly.

A shouldConvertFpToSat method was added to control when converting may be profitable. The original fptosi will have a less strict semantics than the fptosisat, with less values that need to produce defined behaviour.

This especially helps on ARM/AArch64 where the vcvt instructions naturally saturate the result.


https://reviews.llvm.org/D111976

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/test/CodeGen/AArch64/fpclamptosat.ll
  llvm/test/CodeGen/AArch64/fpclamptosat_vec.ll
  llvm/test/CodeGen/ARM/fpclamptosat.ll
  llvm/test/CodeGen/RISCV/fpclamptosat.ll
  llvm/test/CodeGen/Thumb2/mve-fpclamptosat_vec.ll
  llvm/test/CodeGen/WebAssembly/fpclamptosat.ll
  llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll
  llvm/test/CodeGen/X86/fpclamptosat.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111976.380293.patch
Type: text/x-patch
Size: 140548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211018/b5c390e0/attachment-0001.bin>


More information about the llvm-commits mailing list