aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/IR
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-07-30 20:45:05 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-07-30 20:45:05 +0000
commitf34dc428fa577d6d5d71ab3a1f9765b4e5da5a4f (patch)
treea86bb2efc2858086c526b79eb798b2de2a04d3cb /unittests/IR
parent80bec28b6645676a7cd9408d780b4c805774ef42 (diff)
downloadexternal_llvm-f34dc428fa577d6d5d71ab3a1f9765b4e5da5a4f.zip
external_llvm-f34dc428fa577d6d5d71ab3a1f9765b4e5da5a4f.tar.gz
external_llvm-f34dc428fa577d6d5d71ab3a1f9765b4e5da5a4f.tar.bz2
Change behavior of calling bitcasted alias functions.
It will now only convert the arguments / return value and call the underlying function if the types are able to be bitcasted. This avoids using fp<->int conversions that would occur before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187444 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/IR')
-rw-r--r--unittests/IR/InstructionsTest.cpp77
1 files changed, 70 insertions, 7 deletions
diff --git a/unittests/IR/InstructionsTest.cpp b/unittests/IR/InstructionsTest.cpp
index 3aa30af..34d662d 100644
--- a/unittests/IR/InstructionsTest.cpp
+++ b/unittests/IR/InstructionsTest.cpp
@@ -116,11 +116,35 @@ TEST(InstructionsTest, BranchInst) {
TEST(InstructionsTest, CastInst) {
LLVMContext &C(getGlobalContext());
- Type* Int8Ty = Type::getInt8Ty(C);
- Type* Int64Ty = Type::getInt64Ty(C);
- Type* V8x8Ty = VectorType::get(Int8Ty, 8);
- Type* V8x64Ty = VectorType::get(Int64Ty, 8);
- Type* X86MMXTy = Type::getX86_MMXTy(C);
+ Type *Int8Ty = Type::getInt8Ty(C);
+ Type *Int16Ty = Type::getInt16Ty(C);
+ Type *Int32Ty = Type::getInt32Ty(C);
+ Type *Int64Ty = Type::getInt64Ty(C);
+ Type *V8x8Ty = VectorType::get(Int8Ty, 8);
+ Type *V8x64Ty = VectorType::get(Int64Ty, 8);
+ Type *X86MMXTy = Type::getX86_MMXTy(C);
+
+ Type *HalfTy = Type::getHalfTy(C);
+ Type *FloatTy = Type::getFloatTy(C);
+ Type *DoubleTy = Type::getDoubleTy(C);
+
+ Type *V2Int32Ty = VectorType::get(Int32Ty, 2);
+ Type *V2Int64Ty = VectorType::get(Int64Ty, 2);
+ Type *V4Int16Ty = VectorType::get(Int16Ty, 4);
+
+ Type *Int32PtrTy = PointerType::get(Int32Ty, 0);
+ Type *Int64PtrTy = PointerType::get(Int64Ty, 0);
+
+ Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1);
+ Type *Int64PtrAS1Ty = PointerType::get(Int64Ty, 1);
+
+ Type *V2Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 2);
+ Type *V2Int64PtrAS1Ty = VectorType::get(Int64PtrAS1Ty, 2);
+ Type *V4Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 4);
+ Type *V4Int64PtrAS1Ty = VectorType::get(Int64PtrAS1Ty, 4);
+
+ Type *V2Int64PtrTy = VectorType::get(Int64PtrTy, 2);
+ Type *V2Int32PtrTy = VectorType::get(Int32PtrTy, 2);
const Constant* c8 = Constant::getNullValue(V8x8Ty);
const Constant* c64 = Constant::getNullValue(V8x64Ty);
@@ -132,9 +156,48 @@ TEST(InstructionsTest, CastInst) {
EXPECT_TRUE(CastInst::isCastable(V8x8Ty, V8x64Ty));
EXPECT_EQ(CastInst::Trunc, CastInst::getCastOpcode(c64, true, V8x8Ty, true));
EXPECT_EQ(CastInst::SExt, CastInst::getCastOpcode(c8, true, V8x64Ty, true));
-}
-
+ EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, X86MMXTy));
+ EXPECT_FALSE(CastInst::isBitCastable(X86MMXTy, V8x8Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, X86MMXTy));
+ EXPECT_FALSE(CastInst::isBitCastable(V8x64Ty, V8x8Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(V8x8Ty, V8x64Ty));
+
+ // Check address space casts are rejected since we don't know the sizes here
+ EXPECT_FALSE(CastInst::isBitCastable(Int32PtrTy, Int32PtrAS1Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(Int32PtrAS1Ty, Int32PtrTy));
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrTy, V2Int32PtrAS1Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int32PtrTy));
+ EXPECT_TRUE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int64PtrAS1Ty));
+
+ // Test mismatched number of elements for pointers
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V4Int64PtrAS1Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(V4Int64PtrAS1Ty, V2Int32PtrAS1Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V4Int32PtrAS1Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(Int32PtrTy, V2Int32PtrTy));
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrTy, Int32PtrTy));
+
+ EXPECT_TRUE(CastInst::isBitCastable(Int32PtrTy, Int64PtrTy));
+ EXPECT_FALSE(CastInst::isBitCastable(DoubleTy, FloatTy));
+ EXPECT_FALSE(CastInst::isBitCastable(FloatTy, DoubleTy));
+ EXPECT_TRUE(CastInst::isBitCastable(FloatTy, FloatTy));
+ EXPECT_TRUE(CastInst::isBitCastable(FloatTy, FloatTy));
+ EXPECT_TRUE(CastInst::isBitCastable(FloatTy, Int32Ty));
+ EXPECT_TRUE(CastInst::isBitCastable(Int16Ty, HalfTy));
+ EXPECT_TRUE(CastInst::isBitCastable(Int32Ty, FloatTy));
+ EXPECT_TRUE(CastInst::isBitCastable(V2Int32Ty, Int64Ty));
+
+ EXPECT_TRUE(CastInst::isBitCastable(V2Int32Ty, V4Int16Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(Int32Ty, Int64Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, Int32Ty));
+
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrTy, Int64Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(Int64Ty, V2Int32PtrTy));
+ EXPECT_TRUE(CastInst::isBitCastable(V2Int64PtrTy, V2Int32PtrTy));
+ EXPECT_TRUE(CastInst::isBitCastable(V2Int32PtrTy, V2Int64PtrTy));
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int32Ty, V2Int64Ty));
+ EXPECT_FALSE(CastInst::isBitCastable(V2Int64Ty, V2Int32Ty));
+}
TEST(InstructionsTest, VectorGep) {
LLVMContext &C(getGlobalContext());