<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I looked at the analysis in the bug report and I think I agree with your assessment. Perhaps you can use Nuno's technique to verify the optimization with a SMT solver?<div><br></div><div>As for the patch itself, (assuming the analysis is correct), the patch is trivially correct. The only adjustment I would make is mechanical:</div><div><br></div><div><div>+        } else { // logical shift left or right</div><div>+          if (Shift->getOpcode() == Instruction::Shl) {</div><div>+            CanFold = Shift->hasNoSignedWrap() || !ICI.isSigned();</div><div>+          } else { // logical shift right</div><div>+            CanFold = true;</div><div>+          }</div><div>         }</div><div><br></div><div>I would have combined the else and the first if to</div><div>} else if (Shift->getOpcode() == Instruction::Shl) {</div><div><br></div><div>Evan</div><div><br></div><div><div>On Nov 21, 2013, at 11:46 AM, Kay Tiong Khoo <<a href="mailto:kkhoo@perfwizard.com">kkhoo@perfwizard.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Detailed description of problem in instcombine's compare optimizer:<br><a href="http://llvm.org/bugs/show_bug.cgi?id=17827">http://llvm.org/bugs/show_bug.cgi?id=17827</a><br><br></div>Fix suggested by Henrique Santos via dev mailing list:<br>
<a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-November/067822.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-November/067822.html</a><br></div>
<span><pr17827.patch></span>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></div></body></html>