[llvm] b3f0c26 - [Analysis] simplify propagation of FMF in recurrences; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 3 14:29:20 PST 2021


Author: Sanjay Patel
Date: 2021-03-03T17:28:10-05:00
New Revision: b3f0c2653b61377413c02ce6f6cdeb452c9a8e79

URL: https://github.com/llvm/llvm-project/commit/b3f0c2653b61377413c02ce6f6cdeb452c9a8e79
DIFF: https://github.com/llvm/llvm-project/commit/b3f0c2653b61377413c02ce6f6cdeb452c9a8e79.diff

LOG: [Analysis] simplify propagation of FMF in recurrences; NFC

This is a mess, but this is hopefully no-functional-change.
The 'Prev' descriptor is only used for min/max recurrences
or when starting a match from a phi, so it should not be a
factor when propagating FMF for fmul/fadd.

The API is confusing (and should be reduced in subsequent steps)
because the "UnsafeAlgebraInst" appears to actually be a placeholder
for a recurrence that does NOT have FMF, but we still want to
treat it as reassociative.

Added: 
    

Modified: 
    llvm/lib/Analysis/IVDescriptors.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp
index ca8cd095d510..7cd9a8d4e10e 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -565,10 +565,6 @@ RecurrenceDescriptor::isConditionalRdxPattern(RecurKind Kind, Instruction *I) {
 RecurrenceDescriptor::InstDesc
 RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
                                         InstDesc &Prev, FastMathFlags FMF) {
-  Instruction *UAI = Prev.getUnsafeAlgebraInst();
-  if (!UAI && isa<FPMathOperator>(I) && !I->hasAllowReassoc())
-    UAI = I; // Found an unsafe (unvectorizable) algebra instruction.
-
   switch (I->getOpcode()) {
   default:
     return InstDesc(false, I);
@@ -587,10 +583,12 @@ RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
     return InstDesc(Kind == RecurKind::Xor, I);
   case Instruction::FDiv:
   case Instruction::FMul:
-    return InstDesc(Kind == RecurKind::FMul, I, UAI);
+    return InstDesc(Kind == RecurKind::FMul, I,
+                    I->hasAllowReassoc() ? nullptr : I);
   case Instruction::FSub:
   case Instruction::FAdd:
-    return InstDesc(Kind == RecurKind::FAdd, I, UAI);
+    return InstDesc(Kind == RecurKind::FAdd, I,
+                    I->hasAllowReassoc() ? nullptr : I);
   case Instruction::Select:
     if (Kind == RecurKind::FAdd || Kind == RecurKind::FMul)
       return isConditionalRdxPattern(Kind, I);
@@ -598,8 +596,7 @@ RecurrenceDescriptor::isRecurrenceInstr(Instruction *I, RecurKind Kind,
   case Instruction::FCmp:
   case Instruction::ICmp:
     if (isIntMinMaxRecurrenceKind(Kind) ||
-        (FMF.noNaNs() && FMF.noSignedZeros() &&
-         isFPMinMaxRecurrenceKind(Kind)))
+        (FMF.noNaNs() && FMF.noSignedZeros() && isFPMinMaxRecurrenceKind(Kind)))
       return isMinMaxSelectCmpPattern(I, Prev);
     return InstDesc(false, I);
   }


        


More information about the llvm-commits mailing list