[PATCH] D6629: x86: Emit LAHF/SAHF instead of PUSHF/POPF

Reid Kleckner rnk at google.com
Wed Aug 5 14:06:19 PDT 2015


rnk added inline comments.

================
Comment at: lib/Target/X86/X86InstrInfo.cpp:3912-3913
@@ +3911,4 @@
+  if ((FromEFLAGS || ToEFLAGS) && (is32 || is64)) {
+    // The flags need to be saved, but saving EFLAGS with PUSHF/POPF is
+    // inefficient. Instead:
+    //   - Save the overflow flag OF into AL using SETO, and restore it using a
----------------
I think we can stengthen this to say that using POPF is incorrect, since it can accidentally reset things like TF and IF, and we don't want to do that.

================
Comment at: lib/Target/X86/X86InstrInfo.cpp:3940
@@ +3939,3 @@
+    if (!AXDead)
+      BuildMI(MBB, MI, DL, get(Push)).addReg(AX, getKillRegState(true));
+    if (FromEFLAGS) {
----------------
I'm concerned that we don't have the right kill states here and below. Unfortunately, I don't know enough to say what we should be doing. :(


http://reviews.llvm.org/D6629





More information about the llvm-commits mailing list