[llvm] [AMDGPU][Scheduler] Scoring system for rematerialization candidates (PR #153092)

Lucas Ramirez via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 20 13:59:56 PDT 2025


================
@@ -2056,36 +2045,22 @@ uint64_t PreRARematStage::ScoredRemat::getFreqDiff(const FreqInfo &Freq) const {
   uint64_t UseOrMax = Freq.Regions[Remat->UseRegion];
   if (!UseOrMax)
     UseOrMax = Freq.MaxFreq;
-
-  // Maximum difference in frequency between defining and using regions.
-  const uint64_t MaxDiff = Freq.MaxFreq - 1;
-  // The difference between defining and using frequency is in the range
-  // [-MaxDiff, MaxDiff], shift it to [0,2 x MaxDiff] to stay in the positive
-  // range, then rescale to the representable range in the final score.
-  const uint64_t FreqDiff = (MaxDiff + (DefOrOne - UseOrMax));
-  if (Freq.RescaleIsDenom)
-    return FreqDiff / Freq.RescaleFactor;
-  return FreqDiff * Freq.RescaleFactor;
+  return DefOrOne - UseOrMax;
 }
 
 void PreRARematStage::ScoredRemat::update(const BitVector &TargetRegions,
                                           ArrayRef<GCNRPTarget> RPTargets,
                                           const FreqInfo &FreqInfo,
                                           bool ReduceSpill) {
-  setNullScore();
-  if (!Remat->maybeBeneficial(TargetRegions, RPTargets))
-    return;
----------------
lucas-rami wrote:

This was redundant with the loop below, which will leave both `MaxFreq` and `RegionImpact` at 0 if the remat is not beneficial anyway.

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


More information about the llvm-commits mailing list