summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-03-26 16:58:40 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-03-26 16:58:40 +0000
commitb22cddf04e5f877632f91a391120cb6261894870 (patch)
tree84ee1745f0a3a165a9a86692a13fd016f3a54f0e /lib/CodeGen/MachinePipeliner.cpp
parent42e9b96ddfd67bb0b581694ee57023a7d0cd70c6 (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328550 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--lib/CodeGen/MachinePipeliner.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/MachinePipeliner.cpp b/lib/CodeGen/MachinePipeliner.cpp
index 8015eda1605..c7c5a4a91d0 100644
--- a/lib/CodeGen/MachinePipeliner.cpp
+++ b/lib/CodeGen/MachinePipeliner.cpp
@@ -2647,7 +2647,6 @@ void SwingSchedulerDAG::generateExistingPhis(
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(SUnit *Source, const SDep &Dep,
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();