[llvm] 2f40f56 - [FPEnv] IRBuilder support for constrained sitofp/uitofp.
Kevin P. Neal via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 09:32:55 PST 2019
Author: Kevin P. Neal
Date: 2019-12-17T12:32:28-05:00
New Revision: 2f40f5681d0d896e592d1b6738d1df17228c68a8
URL: https://github.com/llvm/llvm-project/commit/2f40f5681d0d896e592d1b6738d1df17228c68a8
DIFF: https://github.com/llvm/llvm-project/commit/2f40f5681d0d896e592d1b6738d1df17228c68a8.diff
LOG: [FPEnv] IRBuilder support for constrained sitofp/uitofp.
Added:
Modified:
llvm/include/llvm/IR/IRBuilder.h
llvm/unittests/IR/IRBuilderTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 4d3abac87c45..8179e388fa11 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -2021,10 +2021,16 @@ class IRBuilder : public IRBuilderBase, public Inserter {
}
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);
}
diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp
index 1ea92940b88c..4ceff2d69b88 100644
--- a/llvm/unittests/IR/IRBuilderTest.cpp
+++ b/llvm/unittests/IR/IRBuilderTest.cpp
@@ -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);
More information about the llvm-commits
mailing list