<div dir="ltr">This transform is done by visitSDIV in DAGCombiner.cpp. Its using a trick to optimize division by constant. The basic idea is to replace it by a multiply by constant and a shift right with a few extra instructions needed to handle signedness correctly. Since division is usually a slow operation turning it into multiplies, shifts, adds, etc. are usually a better option. I believe you can disable this behavior by returning true in an override of TargetLowering::isIntDivCheap in your target.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 26, 2020 at 6:26 PM Miguel Iñigo J. Mañalac via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-PH">
<div class="gmail-m_5254539495945580145WordSection1">
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black">Hello LLVM-Dev,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black">Attached are:
<u></u><u></u></span></p>
<p class="gmail-m_5254539495945580145MsoListParagraph"><u></u><span style="font-family:Symbol;color:black"><span>·<span style="font:7pt "Times New Roman"">        
</span></span></span><u></u><span style="font-family:"Meiryo UI",sans-serif;color:black">The DAG after being built<u></u><u></u></span></p>
<p class="gmail-m_5254539495945580145MsoListParagraph"><u></u><span style="font-family:Symbol;color:black"><span>·<span style="font:7pt "Times New Roman"">        
</span></span></span><u></u><span style="font-family:"Meiryo UI",sans-serif;color:black">The DAG before the legalization phase<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black">The DAG illustrated performs a signed division for type i32. As can be seen, the SDIV node was converted to a series of other nodes (which includes a MULHS node). In the target
 lowering class of our target, the SDIV has an operation action of custom. Does anybody know where in between the SelectionDAGBuilder and the Legalization phases the SDIV node got converted? I need the SDIV node to stay as an SDIV node until legalization phase
 (where it will be lowered into a library call). How can this behavior be accomplished? Does the converted series of nodes still perform the expected operation?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black">Thank you very much in advance for your help!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black">Sincerely,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Meiryo UI",sans-serif;color:black">Miguel Inigo J. Manalac (1852)<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
JAPANESE: このメールは、宛先に書かれている方のみに送信することを意図しております。誤ってそれ以外の方に送信された場合は、申し訳ございませんが、送信者までお知らせいただき、受信されたメールを削除していただきますようお願いいたします。また、コンピュータ・ウィルスの混入等によってメールの欠落・不整合・遅滞等が発生し、何らのご不便をおかけすることが生じても弊社はその責任を負いません。 ENGLISH: This e-mail is intended for the person(s) to which it
 is addressed. If you have received it by mistake, please notify the sender and delete the received email. In addition, our company shall not assume any responsibility even if it causes any inconvenience, such as loss of mail, inconsistencies, delays, etc.,
 due to the inclusion of computer viruses.
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>