Skip to content

Commit

Permalink
PHI nodes are not FPMathOperator s
Browse files Browse the repository at this point in the history
Reviewers: chandlerc, arsenm

Reviewed By: arsenm

Subscribers: wdng, arsenm, mcrosier, jlebar, bixia, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58887

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355362 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
sanjoy committed Mar 5, 2019
1 parent 99522ce commit b3779ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/llvm/IR/Operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ class FPMathOperator : public Operator {
case Instruction::ExtractElement:
case Instruction::ShuffleVector:
case Instruction::InsertElement:
case Instruction::PHI:
return false;
default:
return V->getType()->isFPOrFPVectorTy();
Expand Down
3 changes: 1 addition & 2 deletions lib/Analysis/IVDescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,8 @@ RecurrenceDescriptor::isConditionalRdxPattern(
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<FPMathOperator>(I) && !I->isFast())
UAI = I; // Found an unsafe (unvectorizable) algebra instruction.

switch (I->getOpcode()) {
Expand Down
9 changes: 9 additions & 0 deletions unittests/IR/InstructionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,5 +993,14 @@ TEST(InstructionsTest, SkipDebug) {
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<FPMathOperator>(I));
I->deleteValue();
}

} // end anonymous namespace
} // end namespace llvm

0 comments on commit b3779ef

Please sign in to comment.