summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-01-11 21:32:10 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-01-11 21:32:10 +0000
commit7636532c1b6c2776d1f3216994d6c4413b3d0372 (patch)
treed3335932189521175b2d8dfabce5bacb045b0121 /llvm/lib/Transforms
parent38004319fa9d45e4174a382c17fe547b1f00bc59 (diff)
downloadbcm5719-llvm-7636532c1b6c2776d1f3216994d6c4413b3d0372.tar.gz
bcm5719-llvm-7636532c1b6c2776d1f3216994d6c4413b3d0372.zip
LowerTypeTests: Represent the memory region size with the constant size-1.
This means that we can use a shorter instruction sequence in the case where the size is a power of two and on the boundary between two representations. Differential Revision: https://reviews.llvm.org/D28421 llvm-svn: 291706
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/LowerTypeTests.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 4ffec0cce53..deb7e819480 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -270,12 +270,12 @@ class LowerTypeTestsModule {
/// relative to the start address.
Constant *AlignLog2;
- /// ByteArray, Inline, AllOnes: size of the memory region covering members
- /// of this type identifier as a multiple of 2^AlignLog2.
- Constant *Size;
+ /// ByteArray, Inline, AllOnes: one less than the size of the memory region
+ /// covering members of this type identifier as a multiple of 2^AlignLog2.
+ Constant *SizeM1;
- /// ByteArray, Inline, AllOnes: range of the size expressed as a bit width.
- unsigned SizeBitWidth;
+ /// ByteArray, Inline, AllOnes: range of SizeM1 expressed as a bit width.
+ unsigned SizeM1BitWidth;
/// ByteArray: the byte array to test the address against.
Constant *TheByteArray;
@@ -593,8 +593,8 @@ Value *LowerTypeTestsModule::lowerTypeTestCall(Metadata *TypeId, CallInst *CI,
IntPtrTy));
Value *BitOffset = B.CreateOr(OffsetSHR, OffsetSHL);
- Constant *BitSizeConst = ConstantExpr::getZExt(TIL.Size, IntPtrTy);
- Value *OffsetInRange = B.CreateICmpULT(BitOffset, BitSizeConst);
+ Constant *BitSizeConst = ConstantExpr::getZExt(TIL.SizeM1, IntPtrTy);
+ Value *OffsetInRange = B.CreateICmpULE(BitOffset, BitSizeConst);
// If the bit set is all ones, testing against it is unnecessary.
if (TIL.TheKind == TypeTestResolution::AllOnes)
@@ -711,13 +711,13 @@ void LowerTypeTestsModule::lowerTypeTestCalls(
if (BSI.isAllOnes()) {
TIL.TheKind = (BSI.BitSize == 1) ? TypeTestResolution::Single
: TypeTestResolution::AllOnes;
- TIL.SizeBitWidth = (BSI.BitSize < 256) ? 8 : 32;
- TIL.Size =
- ConstantInt::get((BSI.BitSize < 256) ? Int8Ty : Int32Ty, BSI.BitSize);
+ TIL.SizeM1BitWidth = (BSI.BitSize <= 128) ? 7 : 32;
+ TIL.SizeM1 = ConstantInt::get((BSI.BitSize <= 128) ? Int8Ty : Int32Ty,
+ BSI.BitSize - 1);
} else if (BSI.BitSize <= 64) {
TIL.TheKind = TypeTestResolution::Inline;
- TIL.SizeBitWidth = (BSI.BitSize <= 32) ? 5 : 6;
- TIL.Size = ConstantInt::get(Int8Ty, BSI.BitSize);
+ TIL.SizeM1BitWidth = (BSI.BitSize <= 32) ? 5 : 6;
+ TIL.SizeM1 = ConstantInt::get(Int8Ty, BSI.BitSize - 1);
uint64_t InlineBits = 0;
for (auto Bit : BSI.Bits)
InlineBits |= uint64_t(1) << Bit;
@@ -728,9 +728,9 @@ void LowerTypeTestsModule::lowerTypeTestCalls(
(BSI.BitSize <= 32) ? Int32Ty : Int64Ty, InlineBits);
} else {
TIL.TheKind = TypeTestResolution::ByteArray;
- TIL.SizeBitWidth = (BSI.BitSize < 256) ? 8 : 32;
- TIL.Size =
- ConstantInt::get((BSI.BitSize < 256) ? Int8Ty : Int32Ty, BSI.BitSize);
+ TIL.SizeM1BitWidth = (BSI.BitSize <= 128) ? 7 : 32;
+ TIL.SizeM1 = ConstantInt::get((BSI.BitSize <= 128) ? Int8Ty : Int32Ty,
+ BSI.BitSize - 1);
++NumByteArraysCreated;
ByteArrayInfo *BAI = createByteArray(BSI);
TIL.TheByteArray = BAI->ByteArray;
OpenPOWER on IntegriCloud