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

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 6 11:23:31 PST 2026


================
@@ -963,12 +1111,31 @@ bool EarlyIfConverter::shouldConvertIf() {
   unsigned MinCrit = std::min(TBBTrace.getCriticalPath(),
                               FBBTrace.getCriticalPath());
 
-  // Set a somewhat arbitrary limit on the critical path extension we accept.
-  unsigned CritLimit = SchedModel.MispredictPenalty/2;
+  // Set a limit on the critical path extension we accept.
+  // When hard-to-predict analysis is enabled, use full MispredictPenalty for
+  // hard-to-predict branches, half for others. Otherwise use half for all.
+  bool DataDependent = false;
+  if (EnableHardToPredictAnalysis) {
+    DataDependent = isConditionDataDependent();
+  }
----------------
jroelofs wrote:

```suggestion
  if (EnableHardToPredictAnalysis)
    DataDependent = isConditionDataDependent();
```

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


More information about the llvm-commits mailing list