[PATCH] D58887: PHI nodes are not `FPMathOperator` s

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 17:14:33 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL355362: PHI nodes are not `FPMathOperator` s (authored by sanjoy, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58887/new/

https://reviews.llvm.org/D58887

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


Index: llvm/trunk/include/llvm/IR/Operator.h
===================================================================
--- llvm/trunk/include/llvm/IR/Operator.h
+++ llvm/trunk/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: llvm/trunk/lib/Analysis/IVDescriptors.cpp
===================================================================
--- llvm/trunk/lib/Analysis/IVDescriptors.cpp
+++ llvm/trunk/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<FPMathOperator>(I) && !I->isFast())
     UAI = I; // Found an unsafe (unvectorizable) algebra instruction.
 
   switch (I->getOpcode()) {
Index: llvm/trunk/unittests/IR/InstructionsTest.cpp
===================================================================
--- llvm/trunk/unittests/IR/InstructionsTest.cpp
+++ llvm/trunk/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<FPMathOperator>(I));
+  I->deleteValue();
+}
+
 } // end anonymous namespace
 } // end namespace llvm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58887.189240.patch
Type: text/x-patch
Size: 1783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190305/78d4e0dc/attachment.bin>


More information about the llvm-commits mailing list