@@ -286,44 +286,7 @@ class ASTVisitor : public RecursiveASTVisitor<ASTVisitor> {
286286 SplitInstructionVector Splits (Writes.begin (), Writes.end ());
287287 for (const auto &Write : Writes) {
288288 for (const auto &Read : Reads) {
289- // TODO: Probably true instead of false
290- const auto Dependence =
291- mDependence ->depends (mGetInstructionFunction (Write),
292- mGetInstructionFunction (Read), false );
293- if (!Dependence) {
294- continue ;
295- }
296-
297- const auto Direction = Dependence->getDirection (LoopDepth);
298- if (Direction == tsar_impl::Dependence::DVEntry::EQ) {
299- LLVM_DEBUG (dbgs () << " Ignore loop independent dependence\n " );
300- continue ;
301- }
302-
303- // Get direction of the dependency
304- auto Flow = false , Anti = false ;
305- if (Direction == tsar_impl::Dependence::DVEntry::ALL) {
306- Flow = true ;
307- Anti = true ;
308- } else if (Dependence->isFlow ()) {
309- if (Direction == tsar_impl::Dependence::DVEntry::LT ||
310- Direction == tsar_impl::Dependence::DVEntry::LE) {
311- Flow = true ;
312- } else {
313- Anti = true ;
314- }
315- } else if (Dependence->isAnti ()) {
316- if (Direction == tsar_impl::Dependence::DVEntry::LT ||
317- Direction == tsar_impl::Dependence::DVEntry::LE) {
318- Anti = true ;
319- } else {
320- Flow = true ;
321- }
322- }
323-
324- const auto WriteBeforeRead = Write->comesBefore (Read);
325- // If this is bad instructions dependency, can't split between them
326- if (!(WriteBeforeRead && Anti || !WriteBeforeRead && Flow)) {
289+ if (isSplittableDependence (Read, Write, LoopDepth)) {
327290 continue ;
328291 }
329292
@@ -341,6 +304,46 @@ class ASTVisitor : public RecursiveASTVisitor<ASTVisitor> {
341304 return Splits;
342305 }
343306
307+ bool isSplittableDependence (Instruction *Read, Instruction *Write,
308+ const unsigned LoopDepth) const {
309+ // TODO: Probably true instead of false
310+ const auto Dependence = mDependence ->depends (
311+ mGetInstructionFunction (Write), mGetInstructionFunction (Read), false );
312+ if (!Dependence) {
313+ return false ;
314+ }
315+
316+ const auto Direction = Dependence->getDirection (LoopDepth);
317+ if (Direction == tsar_impl::Dependence::DVEntry::EQ) {
318+ return false ;
319+ }
320+
321+ // Get direction of the dependency
322+ auto Flow = false , Anti = false ;
323+ if (Direction == tsar_impl::Dependence::DVEntry::ALL) {
324+ Flow = true ;
325+ Anti = true ;
326+ } else if (Dependence->isFlow ()) {
327+ if (Direction == tsar_impl::Dependence::DVEntry::LT ||
328+ Direction == tsar_impl::Dependence::DVEntry::LE) {
329+ Flow = true ;
330+ } else {
331+ Anti = true ;
332+ }
333+ } else if (Dependence->isAnti ()) {
334+ if (Direction == tsar_impl::Dependence::DVEntry::LT ||
335+ Direction == tsar_impl::Dependence::DVEntry::LE) {
336+ Anti = true ;
337+ } else {
338+ Flow = true ;
339+ }
340+ }
341+
342+ const auto WriteBeforeRead = Write->comesBefore (Read);
343+ // If this is bad instructions dependency, can't split between them
344+ return !(WriteBeforeRead && Anti || !WriteBeforeRead && Flow);
345+ }
346+
344347 void processSplits (const ForStmt *ForStatement,
345348 const SplitInstructionVector &Splits) const {
346349 const auto LoopHeaderSplitter = getLoopHeaderSplitter (ForStatement);
0 commit comments