[llvm] 1f56716 - [llvm] Use hash_combine_range with ranges (NFC) (#137530)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 27 12:31:31 PDT 2025
Author: Kazu Hirata
Date: 2025-04-27T12:31:28-07:00
New Revision: 1f56716a7eb42be67b9e42d11d95b622fdb605e5
URL: https://github.com/llvm/llvm-project/commit/1f56716a7eb42be67b9e42d11d95b622fdb605e5
DIFF: https://github.com/llvm/llvm-project/commit/1f56716a7eb42be67b9e42d11d95b622fdb605e5.diff
LOG: [llvm] Use hash_combine_range with ranges (NFC) (#137530)
Added:
Modified:
llvm/include/llvm/Transforms/Scalar/GVNExpression.h
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Scalar/GVNExpression.h b/llvm/include/llvm/Transforms/Scalar/GVNExpression.h
index 71437953640c9..50cd6ceb9fc0d 100644
--- a/llvm/include/llvm/Transforms/Scalar/GVNExpression.h
+++ b/llvm/include/llvm/Transforms/Scalar/GVNExpression.h
@@ -221,7 +221,7 @@ class BasicExpression : public Expression {
hash_code getHashValue() const override {
return hash_combine(this->Expression::getHashValue(), ValueType,
- hash_combine_range(op_begin(), op_end()));
+ hash_combine_range(operands()));
}
// Debugging support
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index c39585681911a..d3fe218c19a14 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -933,8 +933,7 @@ Error CoverageMapping::loadFunctionRecord(
}
// Don't create records for (filenames, function) pairs we've already seen.
- auto FilenamesHash = hash_combine_range(Record.Filenames.begin(),
- Record.Filenames.end());
+ auto FilenamesHash = hash_combine_range(Record.Filenames);
if (!RecordProvenance[FilenamesHash].insert(hash_value(OrigFuncName)).second)
return Error::success();
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 3a0ae6b01a114..1e378369166c0 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -223,13 +223,11 @@ static unsigned hashCallInst(CallInst *CI) {
// Don't CSE convergent calls in
diff erent basic blocks, because they
// implicitly depend on the set of threads that is currently executing.
if (CI->isConvergent()) {
- return hash_combine(
- CI->getOpcode(), CI->getParent(),
- hash_combine_range(CI->value_op_begin(), CI->value_op_end()));
+ return hash_combine(CI->getOpcode(), CI->getParent(),
+ hash_combine_range(CI->operand_values()));
}
- return hash_combine(
- CI->getOpcode(),
- hash_combine_range(CI->value_op_begin(), CI->value_op_end()));
+ return hash_combine(CI->getOpcode(),
+ hash_combine_range(CI->operand_values()));
}
static unsigned getHashValueImpl(SimpleValue Val) {
@@ -302,12 +300,11 @@ static unsigned getHashValueImpl(SimpleValue Val) {
if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(Inst))
return hash_combine(EVI->getOpcode(), EVI->getOperand(0),
- hash_combine_range(EVI->idx_begin(), EVI->idx_end()));
+ hash_combine_range(EVI->indices()));
if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(Inst))
return hash_combine(IVI->getOpcode(), IVI->getOperand(0),
- IVI->getOperand(1),
- hash_combine_range(IVI->idx_begin(), IVI->idx_end()));
+ IVI->getOperand(1), hash_combine_range(IVI->indices()));
assert((isa<CallInst>(Inst) || isa<ExtractElementInst>(Inst) ||
isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
@@ -322,7 +319,7 @@ static unsigned getHashValueImpl(SimpleValue Val) {
std::swap(LHS, RHS);
return hash_combine(
II->getOpcode(), LHS, RHS,
- hash_combine_range(II->value_op_begin() + 2, II->value_op_end()));
+ hash_combine_range(drop_begin(II->operand_values(), 2)));
}
// gc.relocate is 'special' call: its second and third operands are
@@ -338,9 +335,8 @@ static unsigned getHashValueImpl(SimpleValue Val) {
return hashCallInst(CI);
// Mix in the opcode.
- return hash_combine(
- Inst->getOpcode(),
- hash_combine_range(Inst->value_op_begin(), Inst->value_op_end()));
+ return hash_combine(Inst->getOpcode(),
+ hash_combine_range(Inst->operand_values()));
}
unsigned DenseMapInfo<SimpleValue>::getHashValue(SimpleValue Val) {
@@ -608,9 +604,8 @@ unsigned DenseMapInfo<GEPValue>::getHashValue(const GEPValue &Val) {
if (Val.ConstantOffset.has_value())
return hash_combine(GEP->getOpcode(), GEP->getPointerOperand(),
Val.ConstantOffset.value());
- return hash_combine(
- GEP->getOpcode(),
- hash_combine_range(GEP->value_op_begin(), GEP->value_op_end()));
+ return hash_combine(GEP->getOpcode(),
+ hash_combine_range(GEP->operand_values()));
}
bool DenseMapInfo<GEPValue>::isEqual(const GEPValue &LHS, const GEPValue &RHS) {
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index f914d596f0bf0..414011259fcf1 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1445,9 +1445,9 @@ EliminateDuplicatePHINodesSetBasedImpl(BasicBlock *BB,
// Compute a hash value on the operands. Instcombine will likely have
// sorted them, which helps expose duplicates, but we have to check all
// the operands to be safe in case instcombine hasn't run.
- return static_cast<unsigned>(hash_combine(
- hash_combine_range(PN->value_op_begin(), PN->value_op_end()),
- hash_combine_range(PN->block_begin(), PN->block_end())));
+ return static_cast<unsigned>(
+ hash_combine(hash_combine_range(PN->operand_values()),
+ hash_combine_range(PN->blocks())));
}
static unsigned getHashValue(PHINode *PN) {
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index b156da86e2df2..6f1c7aafe2dcc 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2734,8 +2734,8 @@ struct CSEDenseMapInfo {
static unsigned getHashValue(const Instruction *I) {
assert(canHandle(I) && "Unknown instruction!");
- return hash_combine(I->getOpcode(), hash_combine_range(I->value_op_begin(),
- I->value_op_end()));
+ return hash_combine(I->getOpcode(),
+ hash_combine_range(I->operand_values()));
}
static bool isEqual(const Instruction *LHS, const Instruction *RHS) {
More information about the llvm-commits
mailing list