<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Ping...<br><div style=""><div>On Jul 25, 2014, at 4:11 PM, Yi Jiang <<a href="mailto:yjiang@apple.com">yjiang@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi Ben,</div><div><br></div><div>Thank you for your comments! Here is a new version.  In this version, I still kept some “if” thinking that some operand has been already extracted so I would like to use it directly.  Please let me know if any other comments. </div></div><span><combinecmpV2.patch></span><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">-Yi<br><div><div>On Jul 25, 2014, at 2:12 AM, Benjamin Kramer <<a href="mailto:benny.kra@gmail.com">benny.kra@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Jul 25, 2014 at 1:24 AM, Yi Jiang <<a href="mailto:yjiang@apple.com">yjiang@apple.com</a>> wrote:<br><blockquote type="cite">Hi,<br><br>his patch is trying to fold (icmp ult/ule (A + C1), C3) | (icmp ult/ule (A +<br>C2), C3)  to (icmp ult/ule ((A & ~(C1 ^ C2)) + max(C1, C2)), C3)  .<br>This transformation is legal if C1 ^ C2 is one-bit mask, in other word, C1<br>is only one bit different from C2. In this case, we can “mask” that bit and<br>do just one comparison.<br>A typical example is:<br>isALPHA(c)    ((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z’)<br><br>Now llvm will optimize it to ((c + 191) <=25) || ((c + 159) <=25)<br><br>With this patch, we can optimize it further to:<br>(c & 223) + 191 <= 25<br><br>The binary format of the constants are:<br>191   10111111<br>159   10011111<br>223   11011111<br><br>Here is some experiment result on arm64:<br>The patch shows no regression and improve spec2000 perlbmk 3.8% in<br>test-suite under -O3.<br>We also test the spec2006 400.perlbench with ref size input, it will improve<br>1% under -O3 and 1.2% under -O3+lto+pgo.<br></blockquote><br>Wow, very nice.<br><br><blockquote type="cite">Any comments are appreciated.<br></blockquote><br>The patch could be significantly simplified with the PatternMatch<br>tool. Something like match(LHS, m_Add(m_OneUse(m_Value(A),<br>m_ConstantInt(LAddCst)... could replace your if chain.<br><br>- Ben</div></blockquote></div><br></div></blockquote></div><br></body></html>