[llvm] r328550 - [Pipeliner] Check for affine expression in isLoopCarriedOrder
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 26 09:58:40 PDT 2018
Author: kparzysz
Date: Mon Mar 26 09:58:40 2018
New Revision: 328550
URL: http://llvm.org/viewvc/llvm-project?rev=328550&view=rev
Log:
[Pipeliner] Check for affine expression in isLoopCarriedOrder
The pipeliner must add a loop carried dependence between two memory
operations if the base register is not an affine (linear) exression.
The current implementation doesn't check how the base register is
defined, which allows non-affine expressions, and then the pipeliner
does not add a loop carried dependence when one is needed.
This patch adds code to isLoopCarriedOrder that checks if the base
register of the memory operations is defined by a phi, and the loop
definition for the phi is a constant increment value. This is a very
simple check for a linear expression.
Patch by Brendon Cahoon.
Modified:
llvm/trunk/lib/CodeGen/MachinePipeliner.cpp
Modified: llvm/trunk/lib/CodeGen/MachinePipeliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachinePipeliner.cpp?rev=328550&r1=328549&r2=328550&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachinePipeliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachinePipeliner.cpp Mon Mar 26 09:58:40 2018
@@ -2647,7 +2647,6 @@ void SwingSchedulerDAG::generateExisting
unsigned NumPhis = std::min(NumStages, MaxPhis);
unsigned NewReg = 0;
-
unsigned AccessStage = (LoopValStage != -1) ? LoopValStage : StageScheduled;
// In the epilog, we may need to look back one stage to get the correct
// Phi name because the epilog and prolog blocks execute the same stage.
@@ -3562,6 +3561,19 @@ bool SwingSchedulerDAG::isLoopCarriedDep
if (BaseRegS != BaseRegD)
return true;
+ // Check that the base register is incremented by a constant value for each
+ // iteration.
+ MachineInstr *Def = MRI.getVRegDef(BaseRegS);
+ if (!Def || !Def->isPHI())
+ return true;
+ unsigned InitVal = 0;
+ unsigned LoopVal = 0;
+ getPhiRegs(*Def, BB, InitVal, LoopVal);
+ MachineInstr *LoopDef = MRI.getVRegDef(LoopVal);
+ int D = 0;
+ if (!LoopDef || !TII->getIncrementValue(*LoopDef, D))
+ return true;
+
uint64_t AccessSizeS = (*SI->memoperands_begin())->getSize();
uint64_t AccessSizeD = (*DI->memoperands_begin())->getSize();
More information about the llvm-commits
mailing list