[llvm-dev] Upper 32bits from 64bit value
Sandeep Kumar Singh via llvm-dev
llvm-dev at lists.llvm.org
Sun Sep 27 20:34:37 PDT 2015
Hi Tim,
Thank you for reply.
> llvm::Value *intermediateValue = LLVMIRBuilder->CreateLShr(x64BitValue,
32);
Now I am using below to calculate upper 32bits, I think this is OK,
llvm::Value *intermediateValue = LLVMIRBuilder->CreateAnd(x64BitValue,
0xFFFFFFFF00000000);
intermediateValue = LLVMIRBuilder->CreateLShr(intermediateValue, 32);
//cast value to 32 bit
intermediateValue = castValueByOpSize(intermediateValue, 32);
Regards,
Deep
On Fri, Sep 25, 2015 at 7:12 PM, Tim Northover <t.p.northover at gmail.com>
wrote:
> 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.
>
--
Thanks and Regards,
Sandeep Kumar Singh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150928/bdc44bec/attachment.html>
More information about the llvm-dev
mailing list