[llvm-dev] ConstantFP->getType() is not right

Yafei Liu via llvm-dev
Thu, 26 Sep 2019 02:42:58 -0000

Hi, I want to create a double constant from a float constant, here's my
code:

auto* constFloat1
static_cast<llvm::ConstantFP*>(llvm::ConstantFP::get(llvm::Type::getFloatTy(context),
3.1));

  assert(constFloat1->getType() == llvm::Type::getFloatTy(context));


  auto* constFloat2 llvm::ConstantFP::get(llvm::Type::getDoubleTy(context),
constFloat1->getValueAPF());

  assert(constFloat2->getType() == llvm::Type::getDoubleTy(context));

but the second assert failed, the type of constFloat2 is still float, not
double, why?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190926/4395687a/attachment.html>