<div dir="ltr">On 21 June 2013 15:56, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">If you setOperationAction on SDIVREM and UDIVREM to Custom you can<br>

expand the rtlib call appropriately yourself.</blockquote><div><br></div><div>Tim,</div><div><br></div><div>Just following up.</div><div><br></div><div>I have assigned Custom lowering:</div><div><br></div><div><div>    setOperationAction(ISD::SREM,  MVT::i32, Custom);</div>
<div>    setOperationAction(ISD::UREM,  MVT::i32, Custom);</div><div>    setOperationAction(ISD::SDIVREM, MVT::i32, Custom);</div><div>    setOperationAction(ISD::UDIVREM, MVT::i32, Custom);</div></div><div><br></div><div>
Added it to the LowerOperation() switch and created a LowerDIVREM(SDValue, DAG).</div><div><br></div><div>My idea is to change the DAG this way:</div><div><br></div><div>* {U,S}REM:</div><div>  * up to 32bits: call {U,S}DIVREM result in R1 (Follow through or use MOV)<br>
</div><div>  * 64bits: call {U,S}DIVREM + result in {R2,R3} (Follow through or use MOV)</div><div>* {U,S}DIVREM:</div><div>  * Change the reminder from stack to to R1 / {R2,R3}</div><div><br></div><div>But for that, SelectionDAGLegalize::ExpandDivRemLibCall() has to stop always loading the result from the stack, and that should become a post-processing thing. I'm not sure how to change the result at the end, but I saw that some calls use ARMTargetLowering::ReplaceNodeResults(), would that be the right place for adding my magic?</div>
<div><br></div><div>Does this make sense? Or is it better for me to copy&paste most of the ExpandDivRemLibCall() into LowerDIVREM()?</div><div><br></div><div>cheers,</div><div>--renato</div></div></div></div>