From 57c3d4bed3ee625e548154063e9f6e7ea70d6ed4 Mon Sep 17 00:00:00 2001 From: Brendon Cahoon Date: Thu, 11 Apr 2019 21:57:51 +0000 Subject: [Pipeliner] Fix incorrect loop carried dependence calculation The isLoopCarriedDep function does not correctly compute loop carried dependences when the array index offset is negative or the stride is smallar than the access size. Patch by Denis Antrushin. Differential Revision: https://reviews.llvm.org/D60135 llvm-svn: 358233 --- llvm/lib/CodeGen/MachinePipeliner.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp') diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp index 1e729d4851a..1f7c48fe215 100644 --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -3167,12 +3167,14 @@ bool SwingSchedulerDAG::isLoopCarriedDep(SUnit *Source, const SDep &Dep, // This is the main test, which checks the offset values and the loop // increment value to determine if the accesses may be loop carried. - if (OffsetS >= OffsetD) - return OffsetS + AccessSizeS > DeltaS; - else - return OffsetD + AccessSizeD > DeltaD; + if (AccessSizeS == MemoryLocation::UnknownSize || + AccessSizeD == MemoryLocation::UnknownSize) + return true; - return true; + if (DeltaS != DeltaD || DeltaS < AccessSizeS || DeltaD < AccessSizeD) + return true; + + return (OffsetS + (int64_t)AccessSizeS < OffsetD + (int64_t)AccessSizeD); } void SwingSchedulerDAG::postprocessDAG() { -- cgit v1.2.3