[PATCH] D143090: [LegalizeTypes] Tail call libcalls where possible

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 09:48:57 PST 2023


luke created this revision.
luke added reviewers: asb, craig.topper, lebedev.ri.
Herald added subscribers: pmatos, StephenFan, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
Herald added a project: All.
luke requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, MaskRay.
Herald added a project: LLVM.

When making a libcall when legalizing the result of a node, check if the node is in tail call position. If it is, then generate a tail call instead.

The main issue encountered whilst working on this was that the type legalizer assumes that the root node isn't changed, and actually wrapped it in a handle.
Due to the fact that creating a tail call actually sets the root, I had to remove these bits.

Also since tail calls don't actually return any result node (just a tail call node with a chain), there's nothing for the type legalizer to work with when it analyzes all of the legalized node's uses. 
But because tail call position means that the node was just used by bitcasts/register copies and return nodes (that are now dead), I've just opted to delete them here.

I could be going about this the completely wrong way, any suggestions on how to do this in a more sensible manner are very much welcome.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143090

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/CodeGen/RISCV/double-arith.ll
  llvm/test/CodeGen/RISCV/double-convert.ll
  llvm/test/CodeGen/RISCV/double-intrinsics-strict.ll
  llvm/test/CodeGen/RISCV/double-intrinsics.ll
  llvm/test/CodeGen/RISCV/float-arith.ll
  llvm/test/CodeGen/RISCV/float-bit-preserving-dagcombines.ll
  llvm/test/CodeGen/RISCV/float-convert.ll
  llvm/test/CodeGen/RISCV/float-frem.ll
  llvm/test/CodeGen/RISCV/float-intrinsics-strict.ll
  llvm/test/CodeGen/RISCV/float-intrinsics.ll
  llvm/test/CodeGen/RISCV/fmax-fmin.ll
  llvm/test/CodeGen/RISCV/half-convert.ll
  llvm/test/CodeGen/RISCV/libcall-tail-calls.ll
  llvm/test/CodeGen/RISCV/rv32i-rv64i-float-double.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143090.493992.patch
Type: text/x-patch
Size: 82092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230201/5abef411/attachment-0001.bin>


More information about the llvm-commits mailing list