<div dir="ltr">On Sat, Jun 29, 2013 at 10:07 AM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Jun 29, 2013, at 10:02 AM, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:<br>
<br>
> I can check all the operands twice or just not do the transform. I don't readily see a nicer alternative but I am receptive to suggestions!<br>
><br>
> I figured that divides are worth annihilating with vigor due to how expensive they are and hoped they would be sufficiently uncommon that any wasted effort would be in the noise.<br>
<br>
</div>Eli is right though, this will burn compiler performance in cases that won't matter.  Remember that instcombine is run multiple times through the compiler flow.<br></blockquote><div><br></div><div style>Attached is a patch that doesn't create any new instructions unless it is able to fold the udiv away.</div>
<div style>It splits the work into two steps, analysis and folding. It tried my best to not add overhead to the folding stage by assuming the analysis step gave me good arguments.</div><div style>It is fairly quick and dirty but I wanted to make sure that this was along the lines of what you expected/imagined before I add comments/cleanup/etc.</div>
<div style>I wouldn't be surprised if you had something different in mind as I find this solution less than elegant.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
> If its any consolation, this transform fires on LLVM itself.<br>
<br>
</div>Sounds like a great optimization, we just need a more efficient implementation :)<br>
<span class="HOEnZb"><font color="#888888"><br>
-Chris<br>
<br>
</font></span></blockquote></div><br></div><div class="gmail_extra" style>Thanks</div><div class="gmail_extra" style>-- </div><div class="gmail_extra" style>David Majnemer</div></div>