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

Jonathan Cohen via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 26 09:58:58 PST 2026


================
@@ -55,10 +56,25 @@ BlockInstrLimit("early-ifcvt-limit", cl::init(30), cl::Hidden,
 static cl::opt<bool> Stress("stress-early-ifcvt", cl::Hidden,
   cl::desc("Turn all knobs to 11"));
 
+// Enable analysis of hard-to-predict branches (conditions derived from loads).
+static cl::opt<bool> EnableHardToPredictAnalysis(
+    "enable-early-ifcvt-hard-to-predict", cl::Hidden, cl::init(true),
+    cl::desc("Enable hard-to-predict branch analysis for if-conversion"));
+
+// Limit the number steps we take when searching conditions that depend on
+// values recently loaded from memory
----------------
jcohen-apple wrote:

By excluding loop invariant and constant pool loads I thought that we would cover those cases, but I added an explicit check that the value was loaded within the same loop as a branch, and this check also makes sure that it is within a small number of instructions from the branch.

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


More information about the llvm-commits mailing list