[llvm-dev] Upper 32bits from 64bit value

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 25 06:42:17 PDT 2015


On 24 September 2015 at 22:12, Sandeep Kumar Singh via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I need to fetch lower and higher 32bits from 64bit value. I found
> "CreateLShr" function to fetch lower 32bits,
> llvm::Value *intermediateValue = LLVMIRBuilder->CreateLShr(x64BitValue, 32);

That would give you the upper bits, I think.

> What function I need to use for fetching upper 32bits from 64bit value.

There's multiple ways to get the other half: "x & 0xffffffff" is the
canonical one (LLVM's optimisers will convert the others into that if
they can).

Cheers.

Tim.


More information about the llvm-dev mailing list