[llvm] r359377 - [MCA] Add field `IsEliminated` to class Instruction. NFCI

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 27 04:59:12 PDT 2019


Author: adibiagio
Date: Sat Apr 27 04:59:11 2019
New Revision: 359377

URL: http://llvm.org/viewvc/llvm-project?rev=359377&view=rev
Log:
[MCA] Add field `IsEliminated` to class Instruction. NFCI



Modified:
    llvm/trunk/include/llvm/MCA/Instruction.h
    llvm/trunk/lib/MCA/Stages/DispatchStage.cpp

Modified: llvm/trunk/include/llvm/MCA/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MCA/Instruction.h?rev=359377&r1=359376&r2=359377&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MCA/Instruction.h (original)
+++ llvm/trunk/include/llvm/MCA/Instruction.h Sat Apr 27 04:59:11 2019
@@ -457,10 +457,14 @@ class Instruction : public InstructionBa
   // by a memory dependency.
   unsigned CriticalMemDep;
 
+  // True if this instruction has been optimized at register renaming stage.
+  bool IsEliminated;
+
 public:
   Instruction(const InstrDesc &D)
       : InstructionBase(D), Stage(IS_INVALID), CyclesLeft(UNKNOWN_CYCLES),
-        RCUTokenID(0), CriticalResourceMask(0), CriticalMemDep(0) {}
+        RCUTokenID(0), CriticalResourceMask(0), CriticalMemDep(0),
+        IsEliminated(false) {}
 
   unsigned getRCUTokenID() const { return RCUTokenID; }
   int getCyclesLeft() const { return CyclesLeft; }
@@ -490,15 +494,11 @@ public:
   bool isExecuting() const { return Stage == IS_EXECUTING; }
   bool isExecuted() const { return Stage == IS_EXECUTED; }
   bool isRetired() const { return Stage == IS_RETIRED; }
-
-  bool isEliminated() const {
-    return isReady() && getDefs().size() &&
-           all_of(getDefs(),
-                  [](const WriteState &W) { return W.isEliminated(); });
-  }
+  bool isEliminated() const { return IsEliminated; }
 
   // Forces a transition from state IS_DISPATCHED to state IS_EXECUTED.
   void forceExecuted();
+  void setEliminated() { IsEliminated = true; }
 
   void retire() {
     assert(isExecuted() && "Instruction is in an invalid state!");

Modified: llvm/trunk/lib/MCA/Stages/DispatchStage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MCA/Stages/DispatchStage.cpp?rev=359377&r1=359376&r2=359377&view=diff
==============================================================================
--- llvm/trunk/lib/MCA/Stages/DispatchStage.cpp (original)
+++ llvm/trunk/lib/MCA/Stages/DispatchStage.cpp Sat Apr 27 04:59:11 2019
@@ -95,11 +95,11 @@ Error DispatchStage::dispatch(InstRef IR
     AvailableEntries = 0;
 
   // Check if this is an optimizable reg-reg move.
-  bool IsEliminated = false;
   if (IS.isOptimizableMove()) {
     assert(IS.getDefs().size() == 1 && "Expected a single input!");
     assert(IS.getUses().size() == 1 && "Expected a single output!");
-    IsEliminated = PRF.tryEliminateMove(IS.getDefs()[0], IS.getUses()[0]);
+    if (PRF.tryEliminateMove(IS.getDefs()[0], IS.getUses()[0]))
+      IS.setEliminated();
   }
 
   if (IS.isMemOp())
@@ -114,7 +114,7 @@ Error DispatchStage::dispatch(InstRef IR
   //
   // We also don't update data dependencies for instructions that have been
   // eliminated at register renaming stage.
-  if (!IsEliminated) {
+  if (!IS.isEliminated()) {
     for (ReadState &RS : IS.getUses())
       PRF.addRegisterRead(RS, STI);
   }




More information about the llvm-commits mailing list