diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h index 608f33c3ed54..037f5aed03ee 100644 --- a/llvm/include/llvm/IR/Operator.h +++ b/llvm/include/llvm/IR/Operator.h @@ -379,6 +379,12 @@ public: return false; switch (Opcode) { + case Instruction::FNeg: + case Instruction::FAdd: + case Instruction::FSub: + case Instruction::FMul: + case Instruction::FDiv: + case Instruction::FRem: // FIXME: To clean up and correct the semantics of fast-math-flags, FCmp // should not be treated as a math op, but the other opcodes should. // This would make things consistent with Select/PHI (FP value type @@ -386,13 +392,12 @@ public: // having fast-math-flags). case Instruction::FCmp: return true; - // non math FP Operators (no FMF) - case Instruction::ExtractElement: - case Instruction::ShuffleVector: - case Instruction::InsertElement: - return false; - default: + case Instruction::PHI: + case Instruction::Select: + case Instruction::Call: return V->getType()->isFPOrFPVectorTy(); + default: + return false; } } }; diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp index 8fb5337a2912..3c9dbc7f19d9 100644 --- a/llvm/unittests/IR/IRBuilderTest.cpp +++ b/llvm/unittests/IR/IRBuilderTest.cpp @@ -376,7 +376,7 @@ TEST_F(IRBuilderTest, UnaryOperators) { ASSERT_FALSE(isa(U)); // Test CreateFNegFMF(X) - Instruction *I = cast(V); + Instruction *I = cast(U); I->setHasNoSignedZeros(true); I->setHasNoNaNs(true); Value *VFMF = Builder.CreateFNegFMF(V, I);