<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Sergey,<div class=""><br class=""></div><div class="">You may also want to look at the MSP430 backend implementation. It also uses Custom Inserters to translate selects into branches. Since it is a simpler backend (meaning less lines of code) it is easier to follow.</div><div class=""><br class=""></div><div class="">You mentioned that you want to optimise some cases of selects. This is normally done for you by the DAGCombine code. However, if your architecture has relatively cheap branches, such ‘optimisations’ might not be always desirable. The trunk MSP430 and the AVR targets are affected by this problem, and I worked on a backend that suffers from that too. For those targets, deciding which selects should not be combined into non-branching sequences is difficult, but there are a few cases that are pretty obvious. If your target gets affected by this, you may be interested in supporting this: <a href="http://llvm.1065342.n5.nabble.com/llvm-dev-AVR-MSP430-Code-gen-improvements-for-8-bit-and-16-bit-targets-tc131716.html" class="">http://llvm.1065342.n5.nabble.com/llvm-dev-AVR-MSP430-Code-gen-improvements-for-8-bit-and-16-bit-targets-tc131716.html</a></div><div class=""><br class=""></div><div class="">John</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 12 Oct 2019, at 01:34, Craig Topper via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">SelectionDAG can't have control flow. For X86 we match selects on old CPUs or on types that don't support cmov to pseudo cmov instructions during isel. Those cmov instructions are marked as "UsesCustomInserter" in the InstrInfo td files. X86TargetLowering::EmitInstrWithCustomInserter will then expand those pseudo instructions into control flow by creating new MachineBasicBlocks and branches. Most of that code is in X86TargetLowering::EmitLoweredSelect.<div class=""><br class=""></div><div class=""><br clear="all" class=""><div class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 11, 2019 at 4:20 PM s.ignatov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br class="">
<br class="">
We have the architecture without conditional moves. Which way can we <br class="">
lower select?<br class="">
<br class="">
As we know there was the special pass a long time ago, but it was deleted.<br class="">
<br class="">
commit c3591a0d48ce045bbf5ae0d78a41f3dae4bb99db<br class="">
Author: Chris Lattner <<a href="mailto:sabre@nondot.org" target="_blank" class="">sabre@nondot.org</a>><br class="">
Date: Tue Feb 19 07:49:17 2008 +0000<br class="">
<br class="">
remove the LowerSelect pass. The last client was the old Sparc <br class="">
backend, which is long dead by now.<br class="">
<br class="">
llvm-svn: 47323<br class="">
<br class="">
The problem is that if we use this pass we lose some useful special <br class="">
optimizing cases for selects, e.g. replacing it by min/max.<br class="">
<br class="">
Does anyone have some experience with such architecture?<br class="">
<br class="">
We're trying to generate some "if-then-else" on SelectionDAG now.<br class="">
<br class="">
Could anyone show the way to generate "if-then-else" constructs on <br class="">
SelectionDAG?<br class="">
<br class="">
Thanks in advance,<br class="">
<br class="">
Sergey.<br class="">
<br class="">
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
</blockquote></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div></div></body></html>