Hendrik Greving via llvm-dev
2020-Jul-16 15:43 UTC
[llvm-dev] Selection DAG chain question
I need to lower a node into something in the machine that has side effects, i.e. needs a chain. Specifically it's actually UDIVREM. UDIVREM does not have a chain. I can custom lower UDIVREM into the nodes I want, with chain, I can even chain the new nodes and connect them to entry and root with token factors. But then the new nodes are not chained with respect to other nodes, or not chained with respect to each other, in case there are several UDIVREM. Hence, can I combine or lower into a node that has a chain from a node that hadn't and let the DAG construction chain this into the existing chain? I tried and it seemed to me that I can't. Or is the only way to code prepare before selection DAG into e.g. a custom intrinsic with side effects, to get the desired chain properties? Thanks for any help in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200716/bec5a55f/attachment.html>
On Thu, 16 Jul 2020 at 16:44, Hendrik Greving via llvm-dev <llvm-dev at lists.llvm.org> wrote:> But then the new nodes are not chained with respect to other nodes, or not chained with respect to each other, in case there are several UDIVREM.Do they really need to be chained with each other or anything else? The case I know of is when they get lowered to a libcall. That libcall has effects that mean it needs a chain of some kind, but it doesn't really matter in any other way where in the basic block it happens. As long as it's after its inputs have been created and before its outputs are consumed, everything is fine. And that's handled by the normal value operands. Cheers. Tim.
Hendrik Greving via llvm-dev
2020-Jul-16 18:10 UTC
[llvm-dev] Selection DAG chain question
Re: Do they really need to be chained with each other or anything else Yes. For 2 reasons. Our architecture lowers udivmem into something with 1 producer and 2 consumers. Reason 1) neither the producers nor the consumers must get reordered. Reason 2) one of the consumers might be missing (either the div or mod consumer might not be present. Yet we need to keep the consuming instruction with side effects. The only way to achieve is to add it into the chain. Problem here: divmod does not have a chain. I scanned other architectures, haven't found an example where somebody creates a chain out of thin air. Do you know any? On Thu, Jul 16, 2020 at 10:54 AM Tim Northover <t.p.northover at gmail.com> wrote:> On Thu, 16 Jul 2020 at 16:44, Hendrik Greving via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > But then the new nodes are not chained with respect to other nodes, or > not chained with respect to each other, in case there are several UDIVREM. > > Do they really need to be chained with each other or anything else? > The case I know of is when they get lowered to a libcall. That libcall > has effects that mean it needs a chain of some kind, but it doesn't > really matter in any other way where in the basic block it happens. > > As long as it's after its inputs have been created and before its > outputs are consumed, everything is fine. And that's handled by the > normal value operands. > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200716/f39ccf6c/attachment.html>