[LLVMdev] question on code in PointerIntPair.h

Chris Lattner clattner at apple.com
Fri Oct 9 14:05:40 PDT 2009


On Oct 9, 2009, at 2:02 PM, Maurizio Vitale wrote:

>>>>>> "Chris" == Chris Lattner <clattner at apple.com> writes:
>
>    Chris> On Oct 8, 2009, at 10:50 AM, Maurizio Vitale wrote:
>
>> around line 45 a bitmask is computed as:
>>>
>>> PointerBitMask = ~(uintptr_t)(((intptr_t)1 <<
>>> PtrTraits::NumLowBitsAvailable)-1),
>>>
>>> my question is why is the shift performed on intptr_t? Wouldn't
>>> the following be ok?
>>>
>>> PointerBitMask = ~(((uintptr_t)1 <<
>>> PtrTraits::NumLowBitsAvailable)-1),
>
>    Chris> Hi Maurizio, why do you ask?  Is the existing code causing a
>    Chris> problem?
>
> Not at all (I'm not really a llvm/clang user yet, only an interested
> observer).
>
> The reason is that this particular file has been mentioned on the  
> boost
> developer mailing list in a thread on compressed pointers/integer
> pairs.
>
> I'm working on bringing some code of mine up to boost standards for a
> review and I was tracking down all things in that thread.
>
> I noticed thatyou were doing things differently from me and I was
> wandering if there was a reason that I couldn't see.

They seem equivalent to me.

-Chris



More information about the llvm-dev mailing list