[llvm] 0da8b0f - [MachineScheduler](NFC) Remove separate handling for non-alias loads and stores (#224310)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 04:49:42 PDT 2026


Author: Nathan Corbyn
Date: 2026-09-21T12:49:36+01:00
New Revision: 0da8b0febd7d9105a7bd8e38c576a6a469e2c40c

URL: https://github.com/llvm/llvm-project/commit/0da8b0febd7d9105a7bd8e38c576a6a469e2c40c
DIFF: https://github.com/llvm/llvm-project/commit/0da8b0febd7d9105a7bd8e38c576a6a469e2c40c.diff

LOG: [MachineScheduler](NFC) Remove separate handling for non-alias loads and stores (#224310)

The separate handling of non-alias loads and stores was always extra
complexity with no pay off. Remove this.

Split from #205689

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
    llvm/lib/CodeGen/ScheduleDAGInstrs.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
index 85613c072dc76..b09530f57898c 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h
@@ -15,7 +15,7 @@
 #define LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/SparseMultiSet.h"
 #include "llvm/Analysis/AliasAnalysis.h"
@@ -104,15 +104,7 @@ namespace llvm {
 
   using ValueType = PointerUnion<const Value *, const PseudoSourceValue *>;
 
-  struct UnderlyingObject : PointerIntPair<ValueType, 1, bool> {
-    UnderlyingObject(ValueType V, bool MayAlias)
-        : PointerIntPair<ValueType, 1, bool>(V, MayAlias) {}
-
-    ValueType getValue() const { return getPointer(); }
-    bool mayAlias() const { return getInt(); }
-  };
-
-  using UnderlyingObjectsVector = SmallVector<UnderlyingObject, 4>;
+  using UnderlyingObjectsVector = SmallVector<ValueType, 4>;
 
   /// A ScheduleDAG for scheduling lists of MachineInstr.
   class LLVM_ABI ScheduleDAGInstrs : public ScheduleDAG {

diff  --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
index 6f42de464cb5b..c929276b219f7 100644
--- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
+++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -81,8 +81,8 @@ static cl::opt<bool>
 // output quality. Setting HugeRegion so large that it will never be
 // reached means best-effort, but may be slow.
 
-// When Stores and Loads maps (or NonAliasStores and NonAliasLoads)
-// together hold this many SUs, a reduction of maps will be done.
+// When Stores and Loads maps together hold this many SUs, a reduction of maps
+// will be done.
 static cl::opt<unsigned>
     HugeRegion("dag-maps-huge-region", cl::Hidden, cl::init(500),
                cl::desc("The limit to use while constructing the DAG "
@@ -149,8 +149,7 @@ static bool getUnderlyingObjectsForInstr(const MachineInstr *MI,
         if (PSV->isAliased(&MFI))
           return false;
 
-        bool MayAlias = PSV->mayAlias(&MFI);
-        Objects.emplace_back(PSV, MayAlias);
+        Objects.push_back(PSV);
       } else if (const Value *V = MMO->getValue()) {
         SmallVector<Value *, 4> Objs;
         if (!getUnderlyingObjectsForCodeGen(V, Objs))
@@ -158,7 +157,7 @@ static bool getUnderlyingObjectsForInstr(const MachineInstr *MI,
 
         for (Value *V : Objs) {
           assert(isIdentifiedObject(V));
-          Objects.emplace_back(V, true);
+          Objects.push_back(V);
         }
       } else
         return false;
@@ -742,15 +741,6 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
   // not share any common Value.
   Value2SUsMap Stores, Loads(1 /*TrueMemOrderLatency*/);
 
-  // Certain memory accesses are known to not alias any SU in Stores
-  // or Loads, and have therefore their own 'NonAlias'
-  // domain. E.g. spill / reload instructions never alias LLVM I/R
-  // Values. It would be nice to assume that this type of memory
-  // accesses always have a proper memory operand modelling, and are
-  // therefore never unanalyzable, but this is conservatively not
-  // done.
-  Value2SUsMap NonAliasStores, NonAliasLoads(1 /*TrueMemOrderLatency*/);
-
   // Track all instructions that may raise floating-point exceptions.
   // These do not depend on one other (or normal loads or stores), but
   // must not be rescheduled across global barriers.  Note that we don't
@@ -886,8 +876,6 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
       // Add dependencies against everything below it and clear maps.
       addBarrierChain(Stores);
       addBarrierChain(Loads);
-      addBarrierChain(NonAliasStores);
-      addBarrierChain(NonAliasLoads);
       addBarrierChain(FPExceptions);
 
       continue;
@@ -929,8 +917,6 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
 
       addBarrierChain(Stores);
       addBarrierChain(Loads);
-      addBarrierChain(NonAliasStores);
-      addBarrierChain(NonAliasLoads);
 
       MemOpsProcessed = 0;
       continue;
@@ -947,32 +933,23 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
       if (!ObjsFound) {
         // An unknown store depends on all stores and loads.
         addChainDependencies(SU, Stores);
-        addChainDependencies(SU, NonAliasStores);
         addChainDependencies(SU, Loads);
-        addChainDependencies(SU, NonAliasLoads);
 
         // Map this store to 'UnknownValue'.
         Stores.insert(SU, UnknownValue);
       } else {
         // Add precise dependencies against all previously seen memory
         // accesses mapped to the same Value(s).
-        for (const UnderlyingObject &UnderlObj : Objs) {
-          ValueType V = UnderlObj.getValue();
-          bool ThisMayAlias = UnderlObj.mayAlias();
-
+        for (const ValueType V : Objs) {
           // Add dependencies to previous stores and loads mapped to V.
-          addChainDependencies(SU, (ThisMayAlias ? Stores : NonAliasStores), V);
-          addChainDependencies(SU, (ThisMayAlias ? Loads : NonAliasLoads), V);
+          addChainDependencies(SU, Stores, V);
+          addChainDependencies(SU, Loads, V);
         }
         // Update the store map after all chains have been added to avoid adding
         // self-loop edge if multiple underlying objects are present.
-        for (const UnderlyingObject &UnderlObj : Objs) {
-          ValueType V = UnderlObj.getValue();
-          bool ThisMayAlias = UnderlObj.mayAlias();
+        for (const ValueType V : Objs)
+          Stores.insert(SU, V);
 
-          // Map this store to V.
-          (ThisMayAlias ? Stores : NonAliasStores).insert(SU, V);
-        }
         // The store may have dependencies to unanalyzable loads and
         // stores.
         addChainDependencies(SU, Loads, UnknownValue);
@@ -982,20 +959,17 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
       if (!ObjsFound) {
         // An unknown load depends on all stores.
         addChainDependencies(SU, Stores);
-        addChainDependencies(SU, NonAliasStores);
 
+        // Map this load to 'UnknownValue'.
         Loads.insert(SU, UnknownValue);
       } else {
-        for (const UnderlyingObject &UnderlObj : Objs) {
-          ValueType V = UnderlObj.getValue();
-          bool ThisMayAlias = UnderlObj.mayAlias();
-
+        for (const ValueType V : Objs) {
           // Add precise dependencies against all previously seen stores
           // mapping to the same Value(s).
-          addChainDependencies(SU, (ThisMayAlias ? Stores : NonAliasStores), V);
+          addChainDependencies(SU, Stores, V);
 
           // Map this load to V.
-          (ThisMayAlias ? Loads : NonAliasLoads).insert(SU, V);
+          Loads.insert(SU, V);
         }
         // The load may have dependencies to unanalyzable stores.
         addChainDependencies(SU, Stores, UnknownValue);


        


More information about the llvm-commits mailing list