[llvm] 13ec3dd - [LV] Add a getRecurrenceBinOp and make use of it. NFC

David Green via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 10:22:12 PDT 2020


Author: David Green
Date: 2020-10-15T18:21:41+01:00
New Revision: 13ec3dd66fe4e8d2990da58e1416c881402dc48e

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

LOG: [LV] Add a getRecurrenceBinOp and make use of it. NFC

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/IVDescriptors.h
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h
index da84c5f30326..6e825c7d5351 100644
--- a/llvm/include/llvm/Analysis/IVDescriptors.h
+++ b/llvm/include/llvm/Analysis/IVDescriptors.h
@@ -186,6 +186,10 @@ class RecurrenceDescriptor {
 
   RecurrenceKind getRecurrenceKind() const { return Kind; }
 
+  unsigned getRecurrenceBinOp() const {
+    return getRecurrenceBinOp(getRecurrenceKind());
+  }
+
   MinMaxRecurrenceKind getMinMaxRecurrenceKind() const { return MinMaxKind; }
 
   FastMathFlags getFastMathFlags() const { return FMF; }
@@ -219,7 +223,7 @@ class RecurrenceDescriptor {
   const SmallPtrSet<Instruction *, 8> &getCastInsts() const { return CastInsts; }
 
   /// Returns true if all source operands of the recurrence are SExtInsts.
-  bool isSigned() const{ return IsSigned; }
+  bool isSigned() const { return IsSigned; }
 
   /// Attempts to find a chain of operations from Phi to LoopExitInst that can
   /// be treated as a set of reductions instructions for in-loop reductions.

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 1c8e80cf448f..84135de5f6f7 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4019,8 +4019,8 @@ void InnerLoopVectorizer::fixReduction(PHINode *Phi) {
       RecurrenceDescriptor RdxDesc = Legal->getReductionVars()[Phi];
       if (PreferPredicatedReductionSelect ||
           TTI->preferPredicatedReductionSelect(
-              RdxDesc.getRecurrenceBinOp(RdxDesc.getRecurrenceKind()),
-              Phi->getType(), TargetTransformInfo::ReductionFlags())) {
+              RdxDesc.getRecurrenceBinOp(), Phi->getType(),
+              TargetTransformInfo::ReductionFlags())) {
         auto *VecRdxPhi = cast<PHINode>(getOrCreateVectorValue(Phi, Part));
         VecRdxPhi->setIncomingValueForBlock(
             LI->getLoopFor(LoopVectorBody)->getLoopLatch(), Sel);
@@ -6901,7 +6901,7 @@ void LoopVectorizationCostModel::collectInLoopReductions() {
 
     // If the target would prefer this reduction to happen "in-loop", then we
     // want to record it as such.
-    unsigned Opcode = RdxDesc.getRecurrenceBinOp(RdxDesc.getRecurrenceKind());
+    unsigned Opcode = RdxDesc.getRecurrenceBinOp();
     if (!PreferInLoopReductions &&
         !TTI.preferInLoopReduction(Opcode, Phi->getType(),
                                    TargetTransformInfo::ReductionFlags()))


        


More information about the llvm-commits mailing list