[llvm] r343787 - [llvm-mca] Move field 'AllowZeroMoveEliminationOnly' to class RegisterFile. NFC.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 4 08:20:56 PDT 2018


Author: adibiagio
Date: Thu Oct  4 08:20:56 2018
New Revision: 343787

URL: http://llvm.org/viewvc/llvm-project?rev=343787&view=rev
Log:
[llvm-mca] Move field 'AllowZeroMoveEliminationOnly' to class RegisterFile. NFC.

Flag 'AllowZeroMoveEliminationOnly' should have been a property of the PRF, and
not set at register granularity.

This change also restricts move elimination to writes that update a full
physical register. We assume that there is a strong correlation between
logical registers that allow move elimination, and how those same registers are
allocated to physical registers by the register renamer.

This is still a no functional change, because this experimental code path is
disabled for now. This is done in preparation for another patch that will add
the ability to describe how move elimination works in scheduling models.

Modified:
    llvm/trunk/tools/llvm-mca/include/HardwareUnits/RegisterFile.h
    llvm/trunk/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp

Modified: llvm/trunk/tools/llvm-mca/include/HardwareUnits/RegisterFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/include/HardwareUnits/RegisterFile.h?rev=343787&r1=343786&r2=343787&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/include/HardwareUnits/RegisterFile.h (original)
+++ llvm/trunk/tools/llvm-mca/include/HardwareUnits/RegisterFile.h Thu Oct  4 08:20:56 2018
@@ -64,6 +64,9 @@ class RegisterFile : public HardwareUnit
     // NumMoveEliminated is less than MaxMoveEliminatedPerCycle.
     unsigned NumMoveEliminated;
 
+    // If set, move elimination is restricted to zero-register moves only.
+    bool AllowZeroMoveEliminationOnly;
+
     RegisterMappingTracker(unsigned NumPhysRegisters,
                            unsigned MaxMoveEliminated = 0U)
         : NumPhysRegs(NumPhysRegisters), NumUsedPhysRegs(0),
@@ -104,16 +107,13 @@ class RegisterFile : public HardwareUnit
   //
   // Field `AllowMoveElimination` is set for registers that are used as
   // destination by optimizable register moves.
-  // Field `AllowZeroMoveEliminationOnly` further restricts move elimination
-  // only to zero-register moves.
   struct RegisterRenamingInfo {
     IndexPlusCostPairTy IndexPlusCost;
     llvm::MCPhysReg RenameAs;
     bool AllowMoveElimination;
-    bool AllowZeroMoveEliminationOnly;
     RegisterRenamingInfo()
         : IndexPlusCost(std::make_pair(0U, 1U)), RenameAs(0U),
-          AllowMoveElimination(false), AllowZeroMoveEliminationOnly(false) {}
+          AllowMoveElimination(false) {}
   };
 
   // RegisterMapping objects are mainly used to track physical register

Modified: llvm/trunk/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp?rev=343787&r1=343786&r2=343787&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp (original)
+++ llvm/trunk/tools/llvm-mca/lib/HardwareUnits/RegisterFile.cpp Thu Oct  4 08:20:56 2018
@@ -284,13 +284,31 @@ bool RegisterFile::tryEliminateMove(Writ
   if (RegisterFileIndex != RRITo.IndexPlusCost.first)
     return false;
 
+  // We only allow move elimination for writes that update a full physical
+  // register. On X86, move elimination is possible with 32-bit general purpose
+  // registers because writes to those registers are not partial writes.  If a
+  // register move is a partial write, then we conservatively assume that move
+  // elimination fails, since it would either trigger a partial update, or the
+  // issue of a merge opcode.
+  //
+  // Note that this constraint may be lifted in future.  For example, we could
+  // make this model more flexible, and let users customize the set of registers
+  // (i.e. register classes) that allow move elimination.
+  //
+  // For now, we assume that there is a strong correlation between registers
+  // that allow move elimination, and how those same registers are renamed in
+  // hardware.
+  if (RRITo.RenameAs && RRITo.RenameAs != WS.getRegisterID())
+    if (!WS.clearsSuperRegisters())
+      return false;
+
   RegisterMappingTracker &RMT = RegisterFiles[RegisterFileIndex];
   if (RMT.MaxMoveEliminatedPerCycle &&
       RMT.NumMoveEliminated == RMT.MaxMoveEliminatedPerCycle)
     return false;
 
   bool IsZeroMove = ZeroRegisters[RS.getRegisterID()];
-  if (RRITo.AllowZeroMoveEliminationOnly && !IsZeroMove)
+  if (RMT.AllowZeroMoveEliminationOnly && !IsZeroMove)
     return false;
 
   RMT.NumMoveEliminated++;




More information about the llvm-commits mailing list