<div dir="ltr"><div><div><div>Hi Duncan, David<br><br></div>As per Duncan's suggestions i implemented, the more general way as follow :<br><br><i>if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {<br>    uint32_t BitWidth = CI->getBitWidth();<br>
    APInt LHSKnownZero(BitWidth, 0, 1);<br>    APInt LHSKnownOne(BitWidth, 0, 1);<br>    computeKnownBits(LHS, LHSKnownZero, LHSKnownOne);<br>    APInt RHSKnownZero(BitWidth, 0, 1);<br>    APInt RHSKnownOne(BitWidth, 0, 1);<br>
    computeKnownBits(RHS, RHSKnownZero, RHSKnownOne);<br>    switch (Pred) {<br>    // TODO: Handle for other icmp instructions.<br>    default:<br>      break;<br>    case ICmpInst::ICMP_EQ:<br>      if (((LHSKnownOne & RHSKnownZero) != 0) ||<br>
          ((LHSKnownZero & RHSKnownOne) != 0))                 ---> THIS IS OUR IMPLEMENTATION<br>        return ConstantInt::getFalse(CI->getContext());<br>      break;<br>    case ICmpInst::ICMP_NE:<br>      if (((LHSKnownOne & RHSKnownZero) != 0) ||<br>
          ((LHSKnownZero & RHSKnownOne) != 0))<br>        return ConstantInt::getTrue(CI->getContext());<br>      break;<br>    }<br>  }</i><br><br>Above code passes my test case as well, i confirmed from running make check-all with my test case added.<br>
<br>However, this probably fails for vectors. I am getting one regression for following test case ;<br><br><i>test/Transforms/InstCombine/align-2d-gep.ll (here we are doing some vector store and checking some alignment).<br>
</i><br></div>How can this be resolved? Even when i tried to generalize my code for more trailing zeros rather than just comparing with one, i got the same regression. <br><br></div>Your suggestions/comments are most awaited.<br>
<div><div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 31, 2014 at 1:23 AM, suyog sarda <span dir="ltr"><<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Thanks Duncan for your valuable suggestion.<br><br></div>I got your point, i will update the patch and add test cases for the same.<br>
<br></div>Thanks a lot.<br></div><div class="gmail_extra"><div><div class="h5"><br>
<br><div class="gmail_quote">On Fri, May 30, 2014 at 7:13 PM, Duncan Sands <span dir="ltr"><<a href="mailto:duncan.sands@gmail.com" target="_blank">duncan.sands@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Hi Suyog,<div><br>
<br>
On 30/05/14 15:01, suyog wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Gentle Ping !!<br>
<br>
<a href="http://reviews.llvm.org/D3868" target="_blank">http://reviews.llvm.org/D3868</a><br>
</blockquote>
<br></div>
I only glanced at this but it seems much less general than it could be.<br>
<br>
Suppose you are analysing icmp eq A, B<br>
<br>
Let A_Known_Zero and A_Known_One give the bits of A that are known to be zero/one.  Likewise B_Known_Zero and B_Known_One for B.<br>
<br>
If a bit is known to be zero for A and known to be one for B then A and B cannot be equal.  Likewise, if a bit if known to be one for A and known to be zero for B then A != B.<br>
<br>
Thus, if A_Known_Zero & B_Known_One != 0 then A != B.  Same if A_Known_One & B_Known_Zero != 0.<br>
<br>
I think this covers your case and many more.<br>
<br>
Ciao, Duncan.<div><div><br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><br></div></div><span class=""><font color="#888888">-- <br>With regards,<br>Suyog Sarda<br>
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div></div></div></div></div></div>