From: Peter Collingbourne Date: Fri, 20 Jan 2017 23:22:28 +0000 (+0000) Subject: LowerTypeTests: Simplify; always create SizeM1 with type IntPtrTy, move initializatio... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9aea18bae5609bda1a3e0ab44cf8030c8c37e80a;p=llvm LowerTypeTests: Simplify; always create SizeM1 with type IntPtrTy, move initialization out of if statement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292674 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/LowerTypeTests.cpp b/lib/Transforms/IPO/LowerTypeTests.cpp index 2bd2bb60554..9ceb76a8e35 100644 --- a/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/lib/Transforms/IPO/LowerTypeTests.cpp @@ -602,8 +602,7 @@ Value *LowerTypeTestsModule::lowerTypeTestCall(Metadata *TypeId, CallInst *CI, IntPtrTy)); Value *BitOffset = B.CreateOr(OffsetSHR, OffsetSHL); - Constant *BitSizeConst = ConstantExpr::getZExtOrBitCast(TIL.SizeM1, IntPtrTy); - Value *OffsetInRange = B.CreateICmpULE(BitOffset, BitSizeConst); + Value *OffsetInRange = B.CreateICmpULE(BitOffset, TIL.SizeM1); // If the bit set is all ones, testing against it is unnecessary. if (TIL.TheKind == TypeTestResolution::AllOnes) @@ -832,14 +831,12 @@ void LowerTypeTestsModule::lowerTypeTestCalls( TIL.OffsetedGlobal = ConstantExpr::getGetElementPtr( Int8Ty, CombinedGlobalAddr, ConstantInt::get(IntPtrTy, BSI.ByteOffset)), TIL.AlignLog2 = ConstantInt::get(Int8Ty, BSI.AlignLog2); + TIL.SizeM1 = ConstantInt::get(IntPtrTy, BSI.BitSize - 1); if (BSI.isAllOnes()) { TIL.TheKind = (BSI.BitSize == 1) ? TypeTestResolution::Single : TypeTestResolution::AllOnes; - TIL.SizeM1 = ConstantInt::get((BSI.BitSize <= 128) ? Int8Ty : Int32Ty, - BSI.BitSize - 1); } else if (BSI.BitSize <= 64) { TIL.TheKind = TypeTestResolution::Inline; - TIL.SizeM1 = ConstantInt::get(Int8Ty, BSI.BitSize - 1); uint64_t InlineBits = 0; for (auto Bit : BSI.Bits) InlineBits |= uint64_t(1) << Bit; @@ -850,8 +847,6 @@ void LowerTypeTestsModule::lowerTypeTestCalls( (BSI.BitSize <= 32) ? Int32Ty : Int64Ty, InlineBits); } else { TIL.TheKind = TypeTestResolution::ByteArray; - TIL.SizeM1 = ConstantInt::get((BSI.BitSize <= 128) ? Int8Ty : Int32Ty, - BSI.BitSize - 1); ++NumByteArraysCreated; ByteArrayInfo *BAI = createByteArray(BSI); TIL.TheByteArray = BAI->ByteArray; diff --git a/test/Transforms/LowerTypeTests/export-allones.ll b/test/Transforms/LowerTypeTests/export-allones.ll index 8bfdae40592..fb09a60a5af 100644 --- a/test/Transforms/LowerTypeTests/export-allones.ll +++ b/test/Transforms/LowerTypeTests/export-allones.ll @@ -140,11 +140,11 @@ ; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i32 0) ; CHECK: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to i8*) -; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i8 1 to i8*) +; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i64 1 to i8*) ; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i64 4) ; CHECK: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to i8*) -; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i32 128 to i8*) +; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i64 128 to i8*) ; CHECK: @foo = alias [2048 x i8], getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0) diff --git a/test/Transforms/LowerTypeTests/export-bytearray.ll b/test/Transforms/LowerTypeTests/export-bytearray.ll index f1d1baf79e9..814d164cb19 100644 --- a/test/Transforms/LowerTypeTests/export-bytearray.ll +++ b/test/Transforms/LowerTypeTests/export-bytearray.ll @@ -13,13 +13,13 @@ ; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i32 0) ; CHECK: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to i8*) -; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i8 65 to i8*) +; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i64 65 to i8*) ; CHECK: @__typeid_typeid1_byte_array = hidden alias i8, i8* @bits.1 ; CHECK: @__typeid_typeid1_bit_mask = hidden alias i8, inttoptr (i8 2 to i8*) ; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i64 4) ; CHECK: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to i8*) -; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i32 257 to i8*) +; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i64 257 to i8*) ; CHECK: @__typeid_typeid2_byte_array = hidden alias i8, i8* @bits ; CHECK: @__typeid_typeid2_bit_mask = hidden alias i8, inttoptr (i8 1 to i8*) diff --git a/test/Transforms/LowerTypeTests/export-inline.ll b/test/Transforms/LowerTypeTests/export-inline.ll index 6f73d78d74e..62b3187e9d6 100644 --- a/test/Transforms/LowerTypeTests/export-inline.ll +++ b/test/Transforms/LowerTypeTests/export-inline.ll @@ -12,12 +12,12 @@ ; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i32 0) ; CHECK: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to i8*) -; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i8 3 to i8*) +; CHECK: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i64 3 to i8*) ; CHECK: @__typeid_typeid1_inline_bits = hidden alias i8, inttoptr (i32 9 to i8*) ; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0, i64 4) ; CHECK: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to i8*) -; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i8 33 to i8*) +; CHECK: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i64 33 to i8*) ; CHECK: @__typeid_typeid2_inline_bits = hidden alias i8, inttoptr (i64 8589934593 to i8*) ; CHECK: @foo = alias [2048 x i8], getelementptr inbounds ({ [2048 x i8] }, { [2048 x i8] }* [[G]], i32 0, i32 0)