forked from OSchip/llvm-project
[FPEnv] IRBuilder support for constrained sitofp/uitofp.
This commit is contained in:
parent
ff6567cc77
commit
2f40f5681d
|
@ -2021,10 +2021,16 @@ public:
|
|||
}
|
||||
|
||||
Value *CreateUIToFP(Value *V, Type *DestTy, const Twine &Name = ""){
|
||||
if (IsFPConstrained)
|
||||
return CreateConstrainedFPCast(Intrinsic::experimental_constrained_uitofp,
|
||||
V, DestTy, nullptr, Name);
|
||||
return CreateCast(Instruction::UIToFP, V, DestTy, Name);
|
||||
}
|
||||
|
||||
Value *CreateSIToFP(Value *V, Type *DestTy, const Twine &Name = ""){
|
||||
if (IsFPConstrained)
|
||||
return CreateConstrainedFPCast(Intrinsic::experimental_constrained_sitofp,
|
||||
V, DestTy, nullptr, Name);
|
||||
return CreateCast(Instruction::SIToFP, V, DestTy, Name);
|
||||
}
|
||||
|
||||
|
|
|
@ -222,6 +222,16 @@ TEST_F(IRBuilderTest, ConstrainedFP) {
|
|||
II = cast<IntrinsicInst>(VInt);
|
||||
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fptosi);
|
||||
|
||||
VDouble = Builder.CreateUIToFP(VInt, Builder.getDoubleTy());
|
||||
ASSERT_TRUE(isa<IntrinsicInst>(VDouble));
|
||||
II = cast<IntrinsicInst>(VDouble);
|
||||
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_uitofp);
|
||||
|
||||
VDouble = Builder.CreateSIToFP(VInt, Builder.getDoubleTy());
|
||||
ASSERT_TRUE(isa<IntrinsicInst>(VDouble));
|
||||
II = cast<IntrinsicInst>(VDouble);
|
||||
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_sitofp);
|
||||
|
||||
V = Builder.CreateFPTrunc(VDouble, Type::getFloatTy(Ctx));
|
||||
ASSERT_TRUE(isa<IntrinsicInst>(V));
|
||||
II = cast<IntrinsicInst>(V);
|
||||
|
|
Loading…
Reference in New Issue