[llvm] [CodeGen] [EarlyIfConversion] Prioritize conversion of hard to predict branches (PR #174457)
Jonathan Cohen via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 6 13:45:27 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;
----------------
jcohen-apple wrote:
Not rigorously. I took some values I saw in cases I had looked into and doubled the size. Not very scientific, but I didn't think it would be that impactful.
https://github.com/llvm/llvm-project/pull/174457
More information about the llvm-commits
mailing list