<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div><br></div><div>** Problematic **</div><div>I am looking for advices to share some logic between DAG combine and target lowering.</div><div><br></div><div>Basically, I need to know if a bitcast that is about to be inserted during target specific isel lowering will be eliminated during DAG combine.</div><div><br></div><div>Let me know if there is another, better supported, approach for this kind of problems.</div><div><br></div><div>** Motivating Example **</div><div>The motivating example comes form the lowering of vector code on armv7.</div><div>More specifically, the build_vector node is lowered to a target specific ARMISD::build_vector where all the parameters are bitcasted to floating point types.</div><div><br></div><div>This works well, unless the inserted bitcasts survive until instruction selection. In that case, they incur moves between integer unit and floating point unit that may result in inefficient code.</div><div><br></div><div>Attached motivating_example.ll shows such a case:</div><div>llc -O3 -mtriple thumbv7-apple-ios3 motivating_example.ll -o -</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">     </span>ldr<span class="Apple-tab-span" style="white-space:pre"> </span>r0, [r1]</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre"> </span>ldr<span class="Apple-tab-span" style="white-space:pre"> </span>r1, [r2]</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre"> </span>vmov<span class="Apple-tab-span" style="white-space:pre">        </span>s1, r1</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">   </span>vmov<span class="Apple-tab-span" style="white-space:pre">        </span>s0, r0</div></div><div style="margin: 0px;">Here each ldr, vmov sequences could have been replaced by a simple vld1.32.</div><div><br></div><div>** Proposed Solution **</div><div>Lower to more vector friendly code (using a sequence of insert_vector_elt), when bit casts will not be free.</div><div>The attached patch demonstrates that, but is missing the proper check to know what DAG combine will do (see TODO).</div><div><br></div><div>Thanks for your help.</div><div><br></div><div>Cheers,</div><div><br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica;  font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">-Quentin</div>

</div>
</div></body></html>