[PATCH] D130028: [SelectionDAG] Fix fptoi.sat scalable vector lowering

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 18 10:24:43 PDT 2022


dmgreen created this revision.
dmgreen added reviewers: craig.topper, RKSimon, efriedma, SjoerdMeijer, bjope, ebevhan.
Herald added subscribers: luke957, StephenFan, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls, arichardson.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added subscribers: alextsao1999, pcwang-thead, MaskRay.
Herald added a project: LLVM.

Vector fptosi_sat and fptoui_sat were being expanded by unrolling the vector operation. This doesn't work for scalable vector, so this patch adds a call to TLI.expandFP_TO_INT_SAT if the vector is scalable.

This also needed an adjustment to create SetCC+VSelect as opposed to SelectCC for vectors. These should either be combined into SelectCC or handled as needed by the target. (I went back and forth as to whether this should be used for scalar too, or if the selectcc should be handled differently. This way was at least simpler to get codegen not crashing).

For non-scalable vectors, the unrolled version can sometimes be better than expanding. Especially if the expanded nodes will be unrolled themselves, or the scalar fptoi_sat are legal for the target.  Going by instruction count, this is almost always better, but some of the "i50" saturates are larger. This uses FMINNUM to check whether the the vector operation will transform into `fmin;fmax;vcvt` or `vcvt;fcmp;sel;fcmp;sel`.

Scalable tests are added for AArch64 and RISCV. Some of the AArch64 fptoi_sat operations should be legal, but that will be handled in another patch.


https://reviews.llvm.org/D130028

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/CodeGen/AArch64/fptosi-sat-vector.ll
  llvm/test/CodeGen/AArch64/fptoui-sat-vector.ll
  llvm/test/CodeGen/AArch64/sve-fptosi-sat.ll
  llvm/test/CodeGen/AArch64/sve-fptoui-sat.ll
  llvm/test/CodeGen/RISCV/rvv/fptosi-sat.ll
  llvm/test/CodeGen/RISCV/rvv/fptoui-sat.ll
  llvm/test/CodeGen/Thumb2/mve-fptosi-sat-vector.ll
  llvm/test/CodeGen/Thumb2/mve-fptoui-sat-vector.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130028.445556.patch
Type: text/x-patch
Size: 210607 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220718/02b449ec/attachment-0001.bin>


More information about the llvm-commits mailing list