diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
commit | eb11fae6d08f479c0799db45860a98af528fa6e7 (patch) | |
tree | 44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /unittests/Transforms/Vectorize/VPlanTest.cpp | |
parent | b8a2042aa938069e862750553db0e4d82d25822c (diff) |
Notes
Diffstat (limited to 'unittests/Transforms/Vectorize/VPlanTest.cpp')
-rw-r--r-- | unittests/Transforms/Vectorize/VPlanTest.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/unittests/Transforms/Vectorize/VPlanTest.cpp b/unittests/Transforms/Vectorize/VPlanTest.cpp new file mode 100644 index 000000000000..67712a7cae2e --- /dev/null +++ b/unittests/Transforms/Vectorize/VPlanTest.cpp @@ -0,0 +1,64 @@ +//===- llvm/unittests/Transforms/Vectorize/VPlanTest.cpp - VPlan tests ----===// +// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "../lib/Transforms/Vectorize/VPlan.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Instructions.h" +#include "gtest/gtest.h" + +namespace llvm { +namespace { + +#define CHECK_ITERATOR(Range1, ...) \ + do { \ + std::vector<VPInstruction *> Tmp = {__VA_ARGS__}; \ + EXPECT_EQ((size_t)std::distance(Range1.begin(), Range1.end()), \ + Tmp.size()); \ + for (auto Pair : zip(Range1, make_range(Tmp.begin(), Tmp.end()))) \ + EXPECT_EQ(&std::get<0>(Pair), std::get<1>(Pair)); \ + } while (0) + +TEST(VPInstructionTest, insertBefore) { + VPInstruction *I1 = new VPInstruction(0, {}); + VPInstruction *I2 = new VPInstruction(1, {}); + VPInstruction *I3 = new VPInstruction(2, {}); + + VPBasicBlock VPBB1; + VPBB1.appendRecipe(I1); + + I2->insertBefore(I1); + CHECK_ITERATOR(VPBB1, I2, I1); + + I3->insertBefore(I2); + CHECK_ITERATOR(VPBB1, I3, I2, I1); +} + +TEST(VPInstructionTest, eraseFromParent) { + VPInstruction *I1 = new VPInstruction(0, {}); + VPInstruction *I2 = new VPInstruction(1, {}); + VPInstruction *I3 = new VPInstruction(2, {}); + + VPBasicBlock VPBB1; + VPBB1.appendRecipe(I1); + VPBB1.appendRecipe(I2); + VPBB1.appendRecipe(I3); + + I2->eraseFromParent(); + CHECK_ITERATOR(VPBB1, I1, I3); + + I1->eraseFromParent(); + CHECK_ITERATOR(VPBB1, I3); + + I3->eraseFromParent(); + EXPECT_TRUE(VPBB1.empty()); +} + +} // namespace +} // namespace llvm |