]> granicus.if.org Git - llvm/commitdiff
PHI nodes are not `FPMathOperator` s
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 5 Mar 2019 01:15:08 +0000 (01:15 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 5 Mar 2019 01:15:08 +0000 (01:15 +0000)
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

include/llvm/IR/Operator.h
lib/Analysis/IVDescriptors.cpp
unittests/IR/InstructionsTest.cpp

index 613d4342ef5fcecd8e389636319fb216f53807fd..fefb13c66d455266f5c97a1d1edde3f884514c14 100644 (file)
@@ -379,6 +379,7 @@ public:
     case Instruction::ExtractElement:
     case Instruction::ShuffleVector:
     case Instruction::InsertElement:
+    case Instruction::PHI:
       return false;
     default:
       return V->getType()->isFPOrFPVectorTy();
index a452a52b94de75e7aa0b82efb7aa41b56aee5d57..555e3c9ed4570cceb82952d390f0e7b33733d401 100644 (file)
@@ -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()) {
index 94f37251e60bcfc6cae3c087298efe816e66f3ec..3b2bd6fa81b0f398ecbcb5bd16464562ed9b8bcc 100644 (file)
@@ -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