<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 8, 2013 at 5:44 AM, Jay Foad <span dir="ltr"><<a href="mailto:jay.foad@gmail.com" target="_blank">jay.foad@gmail.com</a>></span> wrote:<br>
<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"><div dir="ltr"><div class="im">On 8 July 2013 12:53, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@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">InstCombine: Fold X-C1 <u 2 -> (X & -2) == C1<br>

</blockquote></div></div><div class="gmail_extra"><br></div></div><div class="gmail_extra">How about:</div><div class="gmail_extra"><br></div><div class="gmail_extra">* Generalizing for any power of two, e.g. X-C1 <u 16 -> (X & -16) == C1 iff (C1 & 15) == 0 </div>
</div></blockquote><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"><div dir="ltr">
<div class="gmail_extra">* Implementing the complement, C1-X <u 2 -> (X | 1) == C1 iff (C1 & 1) == 1</div></div></blockquote><div><br></div><div style>I actually already have the first one implemented. I just wanted to wait because the general transform suffers in the following case:</div>
<div style><br></div><div style>x - 0xfffffff0 < 16<br></div><div style><br></div><div style>becomes</div><div style><br></div><div style><div>  %and = and i32 %x, -16</div><div>  %cmp = icmp eq i32 %and, -16</div><div>
<br></div><div style>instead of</div><div style><br></div><div style> %cmp = icmp ugt i32 %x, -17<br></div></div><div> </div><div style>I only wanted to handle the reverse transform for the moment. The generalized case will be in before the middle of the week, it requires instcombine recognizing patterns like the above and "doing the right thing (tm)".</div>
<div style><br></div><div style>Thanks for the suggestion on the complement though, I'll look into that.</div><div><br></div><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">
<div dir="ltr"><span class=""><font color="#888888"><div class="gmail_extra"><br></div><div class="gmail_extra">Jay.</div></font></span></div>
</blockquote></div><br></div></div>