[llvm-branch-commits] [llvm] 554be30 - [SLP] reduce code duplication in processing reductions; NFC

Sanjay Patel via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 12 13:10:07 PST 2021


Author: Sanjay Patel
Date: 2021-01-12T16:03:57-05:00
New Revision: 554be30a42802d66807f93e4671a518c1c04e0f8

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

LOG: [SLP] reduce code duplication in processing reductions; NFC

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index ff22572782e2..04bdc74c7879 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6867,38 +6867,29 @@ class HorizontalReduction {
       if (I && I != Phi &&
           (!RdxLeafVal || OpData == RdxLeafVal || IsRdxInst)) {
         // Only handle trees in the current basic block.
-        if (!RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst)) {
-          // I is an extra argument for TreeN (its parent operation).
-          markExtraArg(Stack.back(), I);
-          continue;
-        }
-
         // Each tree node needs to have minimal number of users except for the
         // ultimate reduction.
-        if (!RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
-          // I is an extra argument for TreeN (its parent operation).
-          markExtraArg(Stack.back(), I);
-          continue;
-        }
-
-        if (IsRdxInst) {
-          // We need to be able to reassociate the reduction operations.
-          if (!OpData.isAssociative(I)) {
+        if (RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst) &&
+            RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) && I != B) {
+          if (IsRdxInst) {
+            // We need to be able to reassociate the reduction operations.
+            if (!OpData.isAssociative(I)) {
+              // I is an extra argument for TreeN (its parent operation).
+              markExtraArg(Stack.back(), I);
+              continue;
+            }
+          } else if (RdxLeafVal && RdxLeafVal != OpData) {
+            // Make sure that the opcodes of the operations that we are going to
+            // reduce match.
             // I is an extra argument for TreeN (its parent operation).
             markExtraArg(Stack.back(), I);
             continue;
+          } else if (!RdxLeafVal) {
+            RdxLeafVal = OpData;
           }
-        } else if (RdxLeafVal && RdxLeafVal != OpData) {
-          // Make sure that the opcodes of the operations that we are going to
-          // reduce match.
-          // I is an extra argument for TreeN (its parent operation).
-          markExtraArg(Stack.back(), I);
+          Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
           continue;
-        } else if (!RdxLeafVal) {
-          RdxLeafVal = OpData;
         }
-        Stack.push_back(std::make_pair(I, OpData.getFirstOperandIndex()));
-        continue;
       }
       // NextV is an extra argument for TreeN (its parent operation).
       markExtraArg(Stack.back(), NextV);


        


More information about the llvm-branch-commits mailing list