mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
Use present fast-math flags when applicable in CreateBinOp
We were previously not adding fast-math flags through CreateBinOp() when it happened to be making a floating point binary operator. This patch updates it to do so similarly to directly calling CreateF*(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196438 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e4b236cf59
commit
faf4d59137
@ -832,11 +832,15 @@ public:
|
||||
}
|
||||
|
||||
Value *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Value *LHS, Value *RHS, const Twine &Name = "") {
|
||||
Value *LHS, Value *RHS, const Twine &Name = "",
|
||||
MDNode *FPMathTag = 0) {
|
||||
if (Constant *LC = dyn_cast<Constant>(LHS))
|
||||
if (Constant *RC = dyn_cast<Constant>(RHS))
|
||||
return Insert(Folder.CreateBinOp(Opc, LC, RC), Name);
|
||||
return Insert(BinaryOperator::Create(Opc, LHS, RHS), Name);
|
||||
llvm::Instruction *BinOp = BinaryOperator::Create(Opc, LHS, RHS);
|
||||
if (isa<FPMathOperator>(BinOp))
|
||||
BinOp = AddFPMathAttributes(BinOp, FPMathTag, FMF);
|
||||
return Insert(BinOp, Name);
|
||||
}
|
||||
|
||||
Value *CreateNeg(Value *V, const Twine &Name = "",
|
||||
|
@ -147,6 +147,13 @@ TEST_F(IRBuilderTest, FastMathFlags) {
|
||||
FAdd = cast<Instruction>(F);
|
||||
EXPECT_TRUE(FAdd->hasNoNaNs());
|
||||
|
||||
// Now, try it with CreateBinOp
|
||||
F = Builder.CreateBinOp(Instruction::FAdd, F, F);
|
||||
EXPECT_TRUE(Builder.getFastMathFlags().any());
|
||||
ASSERT_TRUE(isa<Instruction>(F));
|
||||
FAdd = cast<Instruction>(F);
|
||||
EXPECT_TRUE(FAdd->hasNoNaNs());
|
||||
|
||||
F = Builder.CreateFDiv(F, F);
|
||||
EXPECT_TRUE(Builder.getFastMathFlags().any());
|
||||
EXPECT_TRUE(Builder.getFastMathFlags().UnsafeAlgebra);
|
||||
|
Loading…
Reference in New Issue
Block a user