This is an archive of the discontinued LLVM Phabricator instance.

[CodeMoverUtils] Add more data dependency related test case
ClosedPublic

Authored by RithikSharma on Jul 10 2020, 3:57 AM.

Details

Summary

This patch adds more test case focusing on data dependency

Diff Detail

Event Timeline

RithikSharma created this revision.Jul 10 2020, 3:57 AM
bmahjour added inline comments.Jul 10 2020, 7:03 AM
llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
697

This should be EXPECT_FALSE!

Whitney added inline comments.Jul 10 2020, 7:42 AM
llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
698

should this be flow dependency? as the dependency is still read after write.

Whitney added inline comments.Jul 10 2020, 11:20 AM
llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp
679

This may make it more clear:

Instruction *LoadA0 = getInstructionByName(F, "tmp0");
Instruction *LoadA1 = getInstructionByName(F, "tmp1");
Instruction *LoadA2 = getInstructionByName(F, "tmp2");
Instruction *LoadA3 = getInstructionByName(F, "tmp3");
Instruction *LoadB2 = getInstructionByName(F, "tmp4");
Instruction *LoadB3 = getInstructionByName(F, "tmp5");
Instruction *StoreA1 = LoadA0->getPrevNode();
Instruction *StoreA0 = StoreA1->getPrevNode();
Instruction *StoreB0 = LoadA0->getNextNode();
Instruction *StoreB1 = LoadA2->getPrevNode();
Instruction *StoreA2 = StoreB1->getPrevNode();

// Input forward dependency
EXPECT_TRUE(isSafeToMoveBefore(*LoadA2, *LoadB2, DT, &PDT, &DI));
// Input backward dependency
EXPECT_TRUE(isSafeToMoveBefore(*LoadA3, *LoadA2, DT, &PDT, &DI));

// Output forward dependency
EXPECT_FALSE(isSafeToMoveBefore(*StoreA0, *LoadA0, DT, &PDT, &DI));
// Output backward dependency
EXPECT_FALSE(isSafeToMoveBefore(*StoreA1, *StoreA0, DT, &PDT, &DI));

// Flow forward dependency
EXPECT_FALSE(isSafeToMoveBefore(*StoreA1, *StoreB0, DT, &PDT, &DI));
// Flow backward dependency
EXPECT_FALSE(isSafeToMoveBefore(*LoadA0, *StoreA1, DT, &PDT, &DI));

// Anti forward dependency
EXPECT_FALSE(isSafeToMoveBefore(*LoadA1, *StoreB1, DT, &PDT, &DI));
// Anti backward dependency
EXPECT_FALSE(isSafeToMoveBefore(*StoreA2, *LoadA1, DT, &PDT, &DI));
       
// No input backward dependency
EXPECT_TRUE(isSafeToMoveBefore(*LoadB2, *LoadA3, DT, &PDT, &DI));
// No input forward dependency
EXPECT_TRUE(isSafeToMoveBefore(*LoadA3, *LoadB3, DT, &PDT, &DI));

// No output forward dependency
EXPECT_TRUE(isSafeToMoveBefore(*StoreA2, *LoadA2, DT, &PDT, &DI));
// No output backward dependency
EXPECT_TRUE(isSafeToMoveBefore(*StoreB1, *StoreA2, DT, &PDT, &DI));

// No flow forward dependency
EXPECT_TRUE(isSafeToMoveBefore(*StoreB0, *StoreA2, DT, &PDT, &DI));
// No flow backward dependency
EXPECT_TRUE(isSafeToMoveBefore(*LoadA1, *StoreB0, DT, &PDT, &DI));

// No anti backward dependency
EXPECT_TRUE(isSafeToMoveBefore(*StoreB0, *LoadA0, DT, &PDT, &DI));
// No anti forward dependency
EXPECT_TRUE(isSafeToMoveBefore(*LoadA0, *LoadA1, DT, &PDT, &DI));
Whitney accepted this revision.Jul 20 2020, 9:39 AM
This revision is now accepted and ready to land.Jul 20 2020, 9:39 AM
RithikSharma marked 3 inline comments as done.Jul 20 2020, 10:11 AM