<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">On a side note: If a register has no uses then all defs of it must be dead, but you can have multiple definitions and uses and still some of the register definitions can be dead. On the other hand I think the Dead flags on virtual registers are mandatory to be present and correct, this is independent of live intervals being available or not.</div><div class=""><br class=""></div><div class="">- Matthias</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 2, 2015, at 1:23 PM, Pete Cooper <<a href="mailto:peter_cooper@apple.com" class="">peter_cooper@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all<div class=""><br class=""></div><div class="">We’ve discovered that this change (which was meant to be a compile-time improvement only and so NFC) is changing behavior.  I’d like to get an idea of how you would all like to proceed.</div><div class=""><br class=""></div><div class="">So the behavioral difference isn’t in CondOpt, but the next pass called AArch64ConditionalCompares.  CondOpt ran first, but AArch64ConditionalCompares was also implicitly using the results of LiveInternvals via MachineTraceMetrics.</div><div class=""><br class=""></div><div class="">On bzip2 decompress, this patch has resulted in AArch64ConditionalCompares *not* performing a transformation because the metrics suggest its not profitable.  This results in performance improving almost 6% on that benchmark.</div><div class=""><br class=""></div><div class="">The specific difference in performance is the branch on line 871 of AArch64ConditionalCompares.  Prior to this patch the ResDepth and HeadDepth would be such that its profitable to do the work.  After the change, that branch finds its not profitable.  Looking in to where we get the data for that branch, MachineTraceMetrics is returning different depths due to the presence of kill/dead flags.</div><div class=""><br class=""></div><div class="">The worrying thing here is that MachineTraceMetrics is implicitly relying on LiveIntervals.  It doesn’t need it, but it silently giving different results before/after LI runs isn’t ideal.  I don’t know whether to document that, or say its a bug or not.</div><div class=""><br class=""></div><div class="">I can think of a few solutions, comments welcome on where to go from here.</div><div class=""><br class=""></div><div class="">1 - Just revert this patch, it wasn’t NFC as it was meant to be.</div><div class="">2 - Make AArch64ConditionalCompares require LiveIntervals.  This is an incremental improvement over what we had before as we’ve at least removed one pass being dependent on LI.</div><div class="">3 - Teach MachineTraceMetrics to use MRI as this patch did for CondOpt. This will only work for virtual register dead def checks, so may not be suitable given physical register dead defs and kill flags will still differ depending on LI.</div><div class="">4 - Leave things as they are as we actually have a performance improvement, and file a PR to try work out why AArch64ConditionalCompares can actually slow things down, i.e., reevaluate its heuristics in light of this data.</div><div class=""><br class=""></div><div class="">BTW, i’ve CCed Gerolf, Yi, and Michael who all did most of the work discovering the change here.  They and I are happy to help work out whats going on an how to proceed.  We can try provide more data, debug dumps, and IR if needed.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pete<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 22, 2015, at 11:08 AM, Pete Cooper <<a href="mailto:peter_cooper@apple.com" class="">peter_cooper@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks Chad and Zhaoshi.<div class=""><br class=""></div><div class="">r235532.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pete<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 22, 2015, at 11:02 AM, Chad Rosier <<a href="mailto:mcrosier@codeaurora.org" class="">mcrosier@codeaurora.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 14px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Zhaoshi gave your patch a LGTM.  Go for it.  Thanks, Pete.<o:p class=""></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""> </span></div><div class=""><div style="border-style: solid none none; border-top-color: rgb(225, 225, 225); border-top-width: 1pt; padding: 3pt 0in 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><b class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="Apple-converted-space"> </span>Pete Cooper [<a href="mailto:peter_cooper@apple.com" class="">mailto:peter_cooper@apple.com</a>]<span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Wednesday, April 22, 2015 1:04 PM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span><a href="mailto:mcrosier@codeaurora.org" class="">mcrosier@codeaurora.org</a><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:zhaoshiz@codeaurora.org" class="">zhaoshiz@codeaurora.org</a>; <a href="mailto:apazos@codeaurora.org" class="">apazos@codeaurora.org</a>; Tim Northover; Jiangning Liu; <a href="mailto:sdmitrouk@accesssoftek.com" class="">sdmitrouk@accesssoftek.com</a>; llvm-commits<br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [PATCH] Check Dest Register Liveness using MRI in CondOpt pass<o:p class=""></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div><div class=""><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class="" type="cite"><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">On Apr 22, 2015, at 8:04 AM, Chad Rosier <<a href="mailto:mcrosier@codeaurora.org" style="color: purple; text-decoration: underline;" class="">mcrosier@codeaurora.org</a>> wrote:<o:p class=""></o:p></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Pete,</span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">I’ve pinged Zhaoshi and Ana using our internal emails.  Hopefully, they can provide some feedback shortly.</span><o:p class=""></o:p></div></div></div></blockquote><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">Thanks Chad.  Sounds good.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">Pete<br class=""><br class=""><o:p class=""></o:p></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class="" type="cite"><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""> </span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Chad</span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""> </span><o:p class=""></o:p></div></div><div class=""><div style="border-style: solid none none; border-top-color: rgb(225, 225, 225); border-top-width: 1pt; padding: 3pt 0in 0in;" class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><b class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span class="apple-converted-space"><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""> </span></span><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">Pete Cooper [<a href="mailto:peter_cooper@apple.com" style="color: purple; text-decoration: underline;" class="">mailto:peter_cooper@apple.com</a>]<span class="apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="apple-converted-space"> </span>Tuesday, April 21, 2015 6:51 PM<br class=""><b class="">To:</b><span class="apple-converted-space"> </span><a href="mailto:mcrosier@codeaurora.org" style="color: purple; text-decoration: underline;" class="">mcrosier@codeaurora.org</a><br class=""><b class="">Cc:</b><span class="apple-converted-space"> </span><a href="mailto:zhaoshiz@codeaurora.org" style="color: purple; text-decoration: underline;" class="">zhaoshiz@codeaurora.org</a>;<span class="Apple-converted-space"> </span><a href="mailto:apazos@codeaurora.org" style="color: purple; text-decoration: underline;" class="">apazos@codeaurora.org</a>; Tim Northover; Jiangning Liu;<span class="Apple-converted-space"> </span><a href="mailto:sdmitrouk@accesssoftek.com" style="color: purple; text-decoration: underline;" class="">sdmitrouk@accesssoftek.com</a>; llvm-commits<br class=""><b class="">Subject:</b><span class="apple-converted-space"> </span>[PATCH] Check Dest Register Liveness using MRI in CondOpt pass</span><o:p class=""></o:p></div></div></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">Hi Chad<o:p class=""></o:p></div></div><div class=""><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D6048&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=MOz2OsIHlXX17Lrpk-BtwnYKseHBxXVQz_wND6pITU8&s=9B2R2lBWI5AMVkJIuTI3PIwEpEEGpjY-JnEQFmBAk-w&e=" style="color: purple; text-decoration: underline;" class=""><span style="color: purple;" class="">http://reviews.llvm.org/D6048</span></a> (everyone CCed here was CCed on it) added register liveness checking to the CondOpt pass.  It does this with<o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div></div><blockquote style="margin: 5pt 0in 5pt 30pt;" class="" type="cite"><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">if (I->getOperand(0).isDead())<o:p class=""></o:p></div></div></div></blockquote><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">However, this requires that some kind of liveness has been run beforehand, so the pass had to require live intervals.  Looking at the pass manager dump, we then invalidated live intervals shortly after CondOpt because other passes don’t preserve it.<o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">Attached is a patch which removes the dependency on LiveIntervals by checking if the def has any uses.  If it has no uses then it was going to be marked dead anyway, so this is equivalent to your original code.  I’ve verified that this passes ‘make check’ and specifically stepped through the examples in combine-comparisons-by-cse.ll in lldb to ensure the behavior was the same.<o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">When building a bitcode containing all of llc with/without this change, it results in one less run of LiveIntervals per MF and saves 4s out of 80s total compile time.<o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class=""> <o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">Thanks,<o:p class=""></o:p></div></div></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;" class="">Pete</div></div></div></div></div></blockquote></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br class=""></div></blockquote></div><br class=""></body></html>