annotate unittests/CodeGen/ScalableVectorMVTsTest.cpp @ 137:dc788094b8e4

force SROA and TailRecursionElimination on non optimize mode for code segment
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 06 Mar 2018 08:58:23 +0900
parents 803732b1fca8
children c2174574ed3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===-------- llvm/unittest/CodeGen/ScalableVectorMVTsTest.cpp ------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 #include "llvm/CodeGen/MachineValueType.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 #include "llvm/CodeGen/ValueTypes.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 #include "llvm/IR/LLVMContext.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 #include "gtest/gtest.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 using namespace llvm;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 namespace {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 TEST(ScalableVectorMVTsTest, IntegerMVTs) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 for (auto VecTy : MVT::integer_scalable_vector_valuetypes()) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 ASSERT_TRUE(VecTy.isValid());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 ASSERT_TRUE(VecTy.isInteger());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 ASSERT_TRUE(VecTy.isVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 ASSERT_TRUE(VecTy.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 ASSERT_TRUE(VecTy.getScalarType().isValid());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 ASSERT_FALSE(VecTy.isFloatingPoint());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 TEST(ScalableVectorMVTsTest, FloatMVTs) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 for (auto VecTy : MVT::fp_scalable_vector_valuetypes()) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 ASSERT_TRUE(VecTy.isValid());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 ASSERT_TRUE(VecTy.isFloatingPoint());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 ASSERT_TRUE(VecTy.isVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 ASSERT_TRUE(VecTy.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 ASSERT_TRUE(VecTy.getScalarType().isValid());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 ASSERT_FALSE(VecTy.isInteger());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 TEST(ScalableVectorMVTsTest, HelperFuncs) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 LLVMContext Ctx;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 // Create with scalable flag
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 EVT Vnx4i32 = EVT::getVectorVT(Ctx, MVT::i32, 4, /*Scalable=*/true);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 ASSERT_TRUE(Vnx4i32.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 // Create with separate MVT::ElementCount
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51 auto EltCnt = MVT::ElementCount(2, true);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52 EVT Vnx2i32 = EVT::getVectorVT(Ctx, MVT::i32, EltCnt);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53 ASSERT_TRUE(Vnx2i32.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 // Create with inline MVT::ElementCount
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
56 EVT Vnx2i64 = EVT::getVectorVT(Ctx, MVT::i64, {2, true});
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
57 ASSERT_TRUE(Vnx2i64.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
58
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
59 // Check that changing scalar types/element count works
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
60 EXPECT_EQ(Vnx2i32.widenIntegerVectorElementType(Ctx), Vnx2i64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
61 EXPECT_EQ(Vnx4i32.getHalfNumVectorElementsVT(Ctx), Vnx2i32);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
62
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
63 // Check that overloaded '*' and '/' operators work
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
64 EXPECT_EQ(EVT::getVectorVT(Ctx, MVT::i64, EltCnt * 2), MVT::nxv4i64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
65 EXPECT_EQ(EVT::getVectorVT(Ctx, MVT::i64, EltCnt / 2), MVT::nxv1i64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
66
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
67 // Check that float->int conversion works
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
68 EVT Vnx2f64 = EVT::getVectorVT(Ctx, MVT::f64, {2, true});
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
69 EXPECT_EQ(Vnx2f64.changeTypeToInteger(), Vnx2i64);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
70
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
71 // Check fields inside MVT::ElementCount
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
72 EltCnt = Vnx4i32.getVectorElementCount();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
73 EXPECT_EQ(EltCnt.Min, 4U);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
74 ASSERT_TRUE(EltCnt.Scalable);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
75
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
76 // Check that fixed-length vector types aren't scalable.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
77 EVT V8i32 = EVT::getVectorVT(Ctx, MVT::i32, 8);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
78 ASSERT_FALSE(V8i32.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
79 EVT V4f64 = EVT::getVectorVT(Ctx, MVT::f64, {4, false});
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
80 ASSERT_FALSE(V4f64.isScalableVector());
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
81
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
82 // Check that MVT::ElementCount works for fixed-length types.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
83 EltCnt = V8i32.getVectorElementCount();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
84 EXPECT_EQ(EltCnt.Min, 8U);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
85 ASSERT_FALSE(EltCnt.Scalable);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
86 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
87
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
88 }