[llvm] [X86][APX] Reuse EFLAGS across multi-predecessor blocks via NF in optimizeCompareInstr (PR #208184)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 8 07:32:19 PDT 2026


================
@@ -3290,6 +3290,21 @@ unsigned X86::getNFVariant(unsigned Opc) {
   return getNewOpcFromTable(X86NFTransformTable, Opc);
 }
 
+unsigned X86::getNFVariantIfClobberRemovable(const MachineInstr &MI,
+                                             const TargetRegisterInfo *TRI) {
+  if (!MI.registerDefIsDead(X86::EFLAGS, TRI))
+    return 0;
+  // For the instructions are ADDrm/ADDmr with relocation, we'll skip the
+  // optimization for replacing non-NF with NF. This is to keep backward
+  // compatiblity with old version of linkers without APX relocation type
+  // support on Linux OS.
+  bool IsWithReloc =
+      X86EnableAPXForRelocation ? false : isAddMemInstrWithRelocation(MI);
+  if (IsWithReloc)
----------------
phoebewang wrote:

```suggestion
  if (!X86EnableAPXForRelocation && isAddMemInstrWithRelocation(MI))
```

https://github.com/llvm/llvm-project/pull/208184


More information about the llvm-commits mailing list