Skip to content

Add support for single reductions in ComplexDeinterleavingPass #112875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix formatting
  • Loading branch information
NickGuy-Arm committed Dec 10, 2024
commit b3550a588a6b2087c27bdc89f0c849951cfb341f
25 changes: 13 additions & 12 deletions llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ static bool isNeg(Value *V);
static Value *getNegOperand(Value *V);

namespace {
template<typename T, typename IterT>
std::optional<T> findCommonBetweenCollections(IterT A, IterT B) {
auto Common = llvm::find_if(A, [B](T I){return llvm::is_contained(B, I);});
if (Common != A.end())
return std::make_optional(*Common);
return std::nullopt;
}
template <typename T, typename IterT>
std::optional<T> findCommonBetweenCollections(IterT A, IterT B) {
auto Common = llvm::find_if(A, [B](T I) { return llvm::is_contained(B, I); });
if (Common != A.end())
return std::make_optional(*Common);
return std::nullopt;
}

class ComplexDeinterleavingLegacyPass : public FunctionPass {
class ComplexDeinterleavingLegacyPass : public FunctionPass {
public:
static char ID;

Expand Down Expand Up @@ -207,7 +207,7 @@ struct ComplexDeinterleavingCompositeNode {
}
}

bool AreOperandsValid() { return OperandsValid; }
bool areOperandsValid() { return OperandsValid; }
};

class ComplexDeinterleavingGraph {
Expand Down Expand Up @@ -1034,13 +1034,14 @@ ComplexDeinterleavingGraph::identifyPartialReduction(Value *R, Value *I) {
if (!isa<VectorType>(R->getType()) || !isa<VectorType>(I->getType()))
return nullptr;

auto CommonUser = findCommonBetweenCollections<Value*>(R->users(), I->users());
auto CommonUser =
findCommonBetweenCollections<Value *>(R->users(), I->users());
if (!CommonUser)
return nullptr;

auto *IInst = dyn_cast<IntrinsicInst>(*CommonUser);
if (!IInst || IInst->getIntrinsicID() !=
Intrinsic::experimental_vector_partial_reduce_add)
Intrinsic::experimental_vector_partial_reduce_add)
return nullptr;

if (NodePtr CN = identifyDotProduct(IInst))
Expand Down Expand Up @@ -1756,7 +1757,7 @@ void ComplexDeinterleavingGraph::identifyReductionNodes() {
bool ComplexDeinterleavingGraph::checkNodes() {

for (NodePtr N : CompositeNodes) {
if (!N->AreOperandsValid())
if (!N->areOperandsValid())
return false;
}

Expand Down
Loading