Skip to content

Revert "Reland [EquivClasses] Introduce members iterator-helper" #130380

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 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions llvm/include/llvm/ADT/EquivalenceClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#ifndef LLVM_ADT_EQUIVALENCECLASSES_H
#define LLVM_ADT_EQUIVALENCECLASSES_H

#include "llvm/ADT/iterator_range.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -179,9 +178,6 @@ class EquivalenceClasses {
member_iterator member_end() const {
return member_iterator(nullptr);
}
iterator_range<member_iterator> members(iterator I) const {
return make_range(member_begin(I), member_end());
}

/// findValue - Return an iterator to the specified value. If it does not
/// exist, end() is returned.
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Analysis/LoopAccessAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,9 @@ void RuntimePointerChecking::groupChecks(
// iteration order within an equivalence class member is only dependent on
// the order in which unions and insertions are performed on the
// equivalence class, the iteration order is deterministic.
for (const auto &MI : DepCands.members(LeaderI)) {
auto PointerI = PositionMap.find(MI.getPointer());
for (auto MI = DepCands.member_begin(LeaderI), ME = DepCands.member_end();
MI != ME; ++MI) {
auto PointerI = PositionMap.find(MI->getPointer());
assert(PointerI != PositionMap.end() &&
"pointer in equivalence class not found in PositionMap");
for (unsigned Pointer : PointerI->second) {
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Analysis/VectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,

for (auto I = ECs.begin(), E = ECs.end(); I != E; ++I) {
uint64_t LeaderDemandedBits = 0;
for (Value *M : ECs.members(I))
for (Value *M : llvm::make_range(ECs.member_begin(I), ECs.member_end()))
LeaderDemandedBits |= DBits[M];

uint64_t MinBW = llvm::bit_width(LeaderDemandedBits);
Expand All @@ -857,15 +857,15 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
// indvars.
// If we are required to shrink a PHI, abandon this entire equivalence class.
bool Abort = false;
for (Value *M : ECs.members(I))
for (Value *M : llvm::make_range(ECs.member_begin(I), ECs.member_end()))
if (isa<PHINode>(M) && MinBW < M->getType()->getScalarSizeInBits()) {
Abort = true;
break;
}
if (Abort)
continue;

for (Value *M : ECs.members(I)) {
for (Value *M : llvm::make_range(ECs.member_begin(I), ECs.member_end())) {
auto *MI = dyn_cast<Instruction>(M);
if (!MI)
continue;
Expand Down
14 changes: 0 additions & 14 deletions llvm/unittests/ADT/EquivalenceClassesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "llvm/ADT/EquivalenceClasses.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

using namespace llvm;
Expand Down Expand Up @@ -67,19 +66,6 @@ TEST(EquivalenceClassesTest, TwoSets) {
EXPECT_FALSE(EqClasses.isEquivalent(i, j));
}

TEST(EquivalenceClassesTest, MembersIterator) {
EquivalenceClasses<int> EC;
EC.unionSets(1, 2);
EC.insert(4);
EC.insert(5);
EC.unionSets(5, 1);
EXPECT_EQ(EC.getNumClasses(), 2u);

EquivalenceClasses<int>::iterator I = EC.findValue(EC.getLeaderValue(1));
EXPECT_THAT(EC.members(I), testing::ElementsAre(5, 1, 2));
EXPECT_EQ(EC.members(EC.end()).begin(), EC.member_end());
}

// Type-parameterized tests: Run the same test cases with different element
// types.
template <typename T> class ParameterizedTest : public testing::Test {};
Expand Down
Loading