[llvm] [MLGO] Saturate out-of-range regalloc priority advice (PR #224062)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 10:00:58 PDT 2026


================
@@ -325,6 +327,16 @@ MLPriorityAdvisor::MLPriorityAdvisor(const MachineFunction &MF,
   Runner->switchContext(MF.getName());
 }
 
+// Converting a NaN or an out-of-range float advice to unsigned is undefined.
+// Saturate instead.
+static unsigned convertAdviceToPriority(double Advice) {
+  if (!(Advice > 0.0)) // Also catches NaN.
----------------
mtrofin wrote:

nan should be a model error, could we assert it at minimum?

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


More information about the llvm-commits mailing list