shashikiran
shashikiran

Reputation: 379

Convert constant Double to Int in llvm IR

Given the following IR,

%1 = call double @llvm.pow.f64(double %conv, double 9.000000e+00)

when the fraction part of second argument is zero, I want to get it(second argument) in int type.

Can someone please suggest a method for this conversion?
Thank you in advance.

Upvotes: 0

Views: 2659

Answers (1)

arrowd
arrowd

Reputation: 34401

There are conversion instructions for this:

fptoui

fptosi

EDIT:

If you wish to convert llvm::ConstantFP, you can call getValueAPF() method, which would return you llvm::APFloat. See documentation on how to convert llvm::APFloat to integer.

Upvotes: 2

Related Questions