Index: include/llvm/IR/Operator.h =================================================================== --- include/llvm/IR/Operator.h +++ include/llvm/IR/Operator.h @@ -379,6 +379,7 @@ case Instruction::ExtractElement: case Instruction::ShuffleVector: case Instruction::InsertElement: + case Instruction::PHI: return false; default: return V->getType()->isFPOrFPVectorTy(); Index: lib/Analysis/IVDescriptors.cpp =================================================================== --- lib/Analysis/IVDescriptors.cpp +++ lib/Analysis/IVDescriptors.cpp @@ -549,9 +549,8 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurrenceKind Kind, InstDesc &Prev, bool HasFunNoNaNAttr) { - bool FP = I->getType()->isFloatingPointTy(); Instruction *UAI = Prev.getUnsafeAlgebraInst(); - if (!UAI && FP && !I->isFast()) + if (!UAI && isa(I) && !I->isFast()) UAI = I; // Found an unsafe (unvectorizable) algebra instruction. switch (I->getOpcode()) { Index: unittests/IR/InstructionsTest.cpp =================================================================== --- unittests/IR/InstructionsTest.cpp +++ unittests/IR/InstructionsTest.cpp @@ -993,5 +993,14 @@ EXPECT_EQ(nullptr, Term->getNextNonDebugInstruction()); } +TEST(InstructionsTest, PhiIsNotFPMathOperator) { + LLVMContext Context; + IRBuilder<> Builder(Context); + MDBuilder MDHelper(Context); + Instruction *I = Builder.CreatePHI(Builder.getDoubleTy(), 0); + EXPECT_FALSE(isa(I)); + I->deleteValue(); +} + } // end anonymous namespace } // end namespace llvm