<div dir="ltr">Hi Sergey,<div><br></div><div>Thanks for working out this new pass to solve the problem.</div><div><br></div><div class="gmail_extra"><div class="gmail_quote">2014-08-11 2:25 GMT+08:00 Sergey Dmitrouk <span dir="ltr"><<a href="mailto:sdmitrouk@accesssoftek.com" target="_blank">sdmitrouk@accesssoftek.com</a>></span>:<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">Hi Jiangning,<br>
<br>
Please find attached patch that adds new pass.  It analyzes branches and<br>
adjusts comparisons and conditions to make compare instructions look the<br>
same, so that CSE pass could remove them.  The patch is big, but half of<br>
it is test file (tried to make it simpler, but it leads to generating<br>
different assembly) and another half is the new pass, which is hard to<br>
break into smaller patches.  I think it demonstrates general<br>
idea (comments in test has comments in C): for code like<br>
<br>
    if ((a > 5 && b == c) || (a >= 5 && b == d)) {<br>
<br>
a is compared with 5 only once with the patch.<br></blockquote><div><br></div><div>I think the solution is fine with me, and statically checking 179.art and 256.bzip2, I don't see regressions any longer, although it seems there are still some redundant compare instructions not captured by machine CSE for 256.bzip2.</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">
<br>
Currently only SUBS and ADDS followed by b.?? are supported.  If this<br>
patch is accepted, it should be possible to additionally:<br>
 * cover TBNZ/TBZ, which are now used for checks like (x < 0) and<br>
   doesn't let my patch optimize this case; does it make sense to use<br>
   one CMP instruction instead of TBNZ followed by CMP?<br></blockquote><div><br></div><div>After Chad committed his patch r<span style="color:rgb(0,0,0);font-size:13px;line-height:1.3em">214518, more opportunities around tbnz/tbz could be exposed, I think it might be worth a try, but I'm not sure how it could benefit benchmarks.</span></div>
<div> </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">
 * handle other conditional instructions (e.g. CSET).<br>
<br>
Comments are welcome, not sure I did it all correctly.  Maybe need to<br>
add command-line option for the pass, TODO comments, debug output,<br>
statistics or rewrite some parts completely.<br></blockquote><div><br></div><div>For your code, it is clear and looks good to me, but it would better Tim can have a look at it as well.</div><div><br></div><div>I'm running benchmarks, and will let you know if I see any abnormal regressions.</div>
<div><br></div><div>Thanks,<br></div><div>-Jiangning</div><div> </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">

<br>
Cheers,<br>
Sergey<br>
</blockquote></div><br></div></div>