[llvm] [CodeGen] [EarlyIfConversion] Prioritize conversion of hard to predict branches (PR #174457)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 12 02:55:26 PST 2026


================
@@ -896,6 +908,142 @@ void EarlyIfConverter::invalidateTraces() {
   Traces->verifyAnalysis();
 }
 
+/// Check if a register's value comes from a memory load by walking the
+/// def-use chain. Results are cached for virtual registers only.
+bool EarlyIfConverter::doOperandsComeFromMemory(Register Reg) {
+  if (!Reg.isVirtual())
+    return false;
+
+  // Check cache first.
+  auto It = OperandMemoryCache.find(Reg);
+  if (It != OperandMemoryCache.end())
+    return It->second;
+
+  // Walk the def-use chain.
+  SmallPtrSet<const MachineInstr *, 16> Visited;
+  SmallVector<const MachineInstr *, 16> Worklist;
+  SmallVector<Register, 16> VisitedRegs;
----------------
fhahn wrote:


```suggestion
  SmallVector<Register> VisitedRegs;
```

Probably best to either always drop it or always set it 


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


More information about the llvm-commits mailing list