[ARM] MVE big endian loads/stores
[llvm-complete.git] / unittests / Transforms / Vectorize / VPlanTest.cpp
blob90f79a3eaf435db5c76a4b9009a21417309f3d1b
1 //===- llvm/unittests/Transforms/Vectorize/VPlanTest.cpp - VPlan tests ----===//
2 //
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #include "../lib/Transforms/Vectorize/VPlan.h"
11 #include "llvm/IR/Instruction.h"
12 #include "llvm/IR/Instructions.h"
13 #include "gtest/gtest.h"
15 namespace llvm {
16 namespace {
18 #define CHECK_ITERATOR(Range1, ...) \
19 do { \
20 std::vector<VPInstruction *> Tmp = {__VA_ARGS__}; \
21 EXPECT_EQ((size_t)std::distance(Range1.begin(), Range1.end()), \
22 Tmp.size()); \
23 for (auto Pair : zip(Range1, make_range(Tmp.begin(), Tmp.end()))) \
24 EXPECT_EQ(&std::get<0>(Pair), std::get<1>(Pair)); \
25 } while (0)
27 TEST(VPInstructionTest, insertBefore) {
28 VPInstruction *I1 = new VPInstruction(0, {});
29 VPInstruction *I2 = new VPInstruction(1, {});
30 VPInstruction *I3 = new VPInstruction(2, {});
32 VPBasicBlock VPBB1;
33 VPBB1.appendRecipe(I1);
35 I2->insertBefore(I1);
36 CHECK_ITERATOR(VPBB1, I2, I1);
38 I3->insertBefore(I2);
39 CHECK_ITERATOR(VPBB1, I3, I2, I1);
42 TEST(VPInstructionTest, eraseFromParent) {
43 VPInstruction *I1 = new VPInstruction(0, {});
44 VPInstruction *I2 = new VPInstruction(1, {});
45 VPInstruction *I3 = new VPInstruction(2, {});
47 VPBasicBlock VPBB1;
48 VPBB1.appendRecipe(I1);
49 VPBB1.appendRecipe(I2);
50 VPBB1.appendRecipe(I3);
52 I2->eraseFromParent();
53 CHECK_ITERATOR(VPBB1, I1, I3);
55 I1->eraseFromParent();
56 CHECK_ITERATOR(VPBB1, I3);
58 I3->eraseFromParent();
59 EXPECT_TRUE(VPBB1.empty());
62 } // namespace
63 } // namespace llvm