From 48dbac5b6b0bc7a03e9af42cb99176abba8d0467 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sat, 16 Jan 2021 11:56:36 -0500 Subject: [PATCH] [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. --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 @@ public: 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 @@ public: auto *I = dyn_cast(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 @@ public: 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 @@ public: 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; -- GitLab