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: http://review.tizen.org/git/?a=commitdiff_plain;h=67addbcacf17afd4ec38f612506f678449f9aae1;p=platform%2Fupstream%2Fllvm.git LowerTypeTests: Simplify; always create SizeM1 with type IntPtrTy, move initialization out of if statement. llvm-svn: 292674 --- diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index 2bd2bb6..9ceb76a 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/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/llvm/test/Transforms/LowerTypeTests/export-allones.ll b/llvm/test/Transforms/LowerTypeTests/export-allones.ll index 8bfdae4..fb09a60 100644 --- a/llvm/test/Transforms/LowerTypeTests/export-allones.ll +++ b/llvm/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/llvm/test/Transforms/LowerTypeTests/export-bytearray.ll b/llvm/test/Transforms/LowerTypeTests/export-bytearray.ll index f1d1baf..814d164 100644 --- a/llvm/test/Transforms/LowerTypeTests/export-bytearray.ll +++ b/llvm/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/llvm/test/Transforms/LowerTypeTests/export-inline.ll b/llvm/test/Transforms/LowerTypeTests/export-inline.ll index 6f73d78..62b3187 100644 --- a/llvm/test/Transforms/LowerTypeTests/export-inline.ll +++ b/llvm/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)