Speed up getABITypeSize by turning a i64 mul and div into an
AND. This is speedup on any reasonable target, but particularly on 32-bit targets where this often turns into a libcall like udivdi3. We know that alignments are a power of two but the compiler doesn't. llvm-svn: 60688
This commit is contained in:
parent
2f9d8458c8
commit
63c38a6630
|
@ -178,8 +178,12 @@ public:
|
||||||
/// that alloca reserves for this type. For example, returns 12 or 16 for
|
/// that alloca reserves for this type. For example, returns 12 or 16 for
|
||||||
/// x86_fp80, depending on alignment.
|
/// x86_fp80, depending on alignment.
|
||||||
uint64_t getABITypeSize(const Type* Ty) const {
|
uint64_t getABITypeSize(const Type* Ty) const {
|
||||||
unsigned char Align = getABITypeAlignment(Ty);
|
// The alignment of a type is always a power of two.
|
||||||
return (getTypeStoreSize(Ty) + Align - 1)/Align*Align;
|
unsigned char AlignMinusOne = getABITypeAlignment(Ty)-1;
|
||||||
|
|
||||||
|
// Round up to the next alignment boundary.
|
||||||
|
uint64_t RoundUp = getTypeStoreSize(Ty) + AlignMinusOne;
|
||||||
|
return RoundUp &= ~uint64_t(AlignMinusOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getABITypeSizeInBits - Return the offset in bits between successive
|
/// getABITypeSizeInBits - Return the offset in bits between successive
|
||||||
|
|
Loading…
Reference in New Issue