<div dir="ltr">I added the lahf/sahf feature to LLVM in the attached patch, without giving the property to any CPU for now: with my patch no CPUs are known to support lahf/sahf, whereas they all were believed to support lahf/sahf before the patch.<div><br></div><div>Doing so causes 20 tests to fail (listed below).</div><div><br></div><div>The problem dates back to 2012-04-27 with r155704 when Benjamin checked in X86TargetLowering::ConvertCmpIfNecessary for Christoph Erhardt to fix <a href="https://llvm.org/bugs/show_bug.cgi?id=6679">PR6679</a>. This happens semi-frequently when materializing the results of floating-point comparisons. I could fix the issue with ConvertCmpIfNecessary as well as the one I added with X86InstrInfo::copyPhysReg, but at this point in time I question whether the problem is worth fixing at all: the copyPhysReg corner case I modified happens *way* less often than ConvertCmpIfNecessary!</div><div><br></div><div>WDYT?</div><div><br></div><div><br></div><div>Failing tests:</div><div> LLVM :: CodeGen/X86/2004-02-22-Casts.ll</div><div> LLVM :: CodeGen/X86/2004-06-10-StackifierCrash.ll</div><div> LLVM :: CodeGen/X86/2006-05-22-FPSetEQ.ll</div><div> LLVM :: CodeGen/X86/2008-05-01-InvalidOrdCompare.ll</div><div> LLVM :: CodeGen/X86/2009-02-12-SpillerBug.ll</div><div> LLVM :: CodeGen/X86/2009-03-09-SpillerBug.ll</div><div> LLVM :: CodeGen/X86/2012-08-28-UnsafeMathCrash.ll</div><div> LLVM :: CodeGen/X86/2012-10-02-DAGCycle.ll</div><div> LLVM :: CodeGen/X86/bitcast-int-to-vector.ll</div><div> LLVM :: CodeGen/X86/block-placement.ll</div><div> LLVM :: CodeGen/X86/cmovcmov.ll</div><div> LLVM :: CodeGen/X86/constpool.ll</div><div> LLVM :: CodeGen/X86/crash.ll</div><div> LLVM :: CodeGen/X86/fabs.ll</div><div> LLVM :: CodeGen/X86/fp-stack-O0-crash.ll</div><div> LLVM :: CodeGen/X86/fp-stack-compare.ll</div><div> LLVM :: CodeGen/X86/fp-stack.ll</div><div> LLVM :: CodeGen/X86/isnan.ll</div><div> LLVM :: CodeGen/X86/setuge.ll</div><div> LLVM :: CodeGen/X86/stack-protector.ll</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 10, 2015 at 6:02 PM, JF Bastien <span dir="ltr"><<a href="mailto:jfb@google.com" target="_blank">jfb@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Ha, you're right. Thanks for pointing it out.<div><br></div><div>How about I add a FeatureLAHFSAHF, and continue using PUSHF/POPF if unsupported?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 10, 2015 at 5:41 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span>On Mon, Aug 10, 2015 at 1:59 PM, JF Bastien via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jfb<br>
Date: Mon Aug 10 15:59:36 2015<br>
New Revision: 244503<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244503&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244503&view=rev</a><br>
Log:<br>
x86: Emit LAHF/SAHF instead of PUSHF/POPF<br>
<br>
NaCl's sandbox doesn't allow PUSHF/POPF out of security concerns (priviledged emulators have forgotten to mask system bits in the past, and EFLAGS's DF bit is a constant source of hilarity). Commit r220529 fixed PR20376 by saving cmpxchg's flags result using EFLAGS, this commit now generated LAHF/SAHF instead, for all of x86 (not just NaCl) because it leads to an overall performance gain over PUSHF/POPF.<br></blockquote><div><br></div></span><div>There's a problem with this: not all x86 CPUs support lahf/sahf in 64-bit mode.<span><font color="#888888"><br><br></font></span></div><span><font color="#888888"><div>-Eli<br></div><div> <br></div></font></span></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>