[llvm-branch-commits] [llvm] 48dbac5 - [SLP] remove unnecessary use of 'OperationData'

Sanjay Patel via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Jan 16 11:15:07 PST 2021


Author: Sanjay Patel
Date: 2021-01-16T13:55:52-05:00
New Revision: 48dbac5b6b0bc7a03e9af42cb99176abba8d0467

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

LOG: [SLP] remove unnecessary use of 'OperationData'

This is another NFC-intended patch to allow matching
intrinsics (example: maxnum) as candidates for reductions.

It's possible that the loop/if logic can be reduced now,
but it's still difficult to understand how this all works.

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 cf7c05e30d06..d5e6dfed8e2c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6814,8 +6814,11 @@ class HorizontalReduction {
 
     ReductionRoot = B;
 
-    // The operation data for the leaf values that we perform a reduction on.
-    OperationData RdxLeafVal;
+    // The opcode for leaf values that we perform a reduction on.
+    // For example: load(x) + load(y) + load(z) + fptoui(w)
+    // The leaf opcode for 'w' does not match, so we don't include it as a
+    // potential candidate for the reduction.
+    unsigned LeafOpcode = 0;
 
     // Post order traverse the reduction tree starting at B. We only handle true
     // trees containing only binary operators.
@@ -6859,9 +6862,9 @@ class HorizontalReduction {
       auto *I = dyn_cast<Instruction>(NextV);
       const OperationData EdgeOpData = getOperationData(I);
       // Continue analysis if the next operand is a reduction operation or
-      // (possibly) a reduced value. If the reduced value opcode is not set,
+      // (possibly) a leaf value. If the leaf value opcode is not set,
       // the first met operation != reduction operation is considered as the
-      // reduced value class.
+      // leaf opcode.
       // Only handle trees in the current basic block.
       // Each tree node needs to have minimal number of users except for the
       // ultimate reduction.
@@ -6869,7 +6872,7 @@ class HorizontalReduction {
       if (I && I != Phi && I != B &&
           RdxTreeInst.hasSameParent(I, B->getParent(), IsRdxInst) &&
           RdxTreeInst.hasRequiredNumberOfUses(I, IsRdxInst) &&
-          (!RdxLeafVal || EdgeOpData == RdxLeafVal || IsRdxInst)) {
+          (!LeafOpcode || LeafOpcode == I->getOpcode() || IsRdxInst)) {
         if (IsRdxInst) {
           // We need to be able to reassociate the reduction operations.
           if (!EdgeOpData.isAssociative(I)) {
@@ -6877,8 +6880,8 @@ class HorizontalReduction {
             markExtraArg(Stack.back(), I);
             continue;
           }
-        } else if (!RdxLeafVal) {
-          RdxLeafVal = EdgeOpData;
+        } else if (!LeafOpcode) {
+          LeafOpcode = I->getOpcode();
         }
         Stack.push_back(std::make_pair(I, EdgeOpData.getFirstOperandIndex()));
         continue;


        


More information about the llvm-branch-commits mailing list