Skip to content

Commit 1f56716

Browse files
[llvm] Use hash_combine_range with ranges (NFC) (#137530)
1 parent 2e93417 commit 1f56716

File tree

5 files changed

+18
-24
lines changed

5 files changed

+18
-24
lines changed

llvm/include/llvm/Transforms/Scalar/GVNExpression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class BasicExpression : public Expression {
221221

222222
hash_code getHashValue() const override {
223223
return hash_combine(this->Expression::getHashValue(), ValueType,
224-
hash_combine_range(op_begin(), op_end()));
224+
hash_combine_range(operands()));
225225
}
226226

227227
// Debugging support

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,7 @@ Error CoverageMapping::loadFunctionRecord(
933933
}
934934

935935
// Don't create records for (filenames, function) pairs we've already seen.
936-
auto FilenamesHash = hash_combine_range(Record.Filenames.begin(),
937-
Record.Filenames.end());
936+
auto FilenamesHash = hash_combine_range(Record.Filenames);
938937
if (!RecordProvenance[FilenamesHash].insert(hash_value(OrigFuncName)).second)
939938
return Error::success();
940939

llvm/lib/Transforms/Scalar/EarlyCSE.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,11 @@ static unsigned hashCallInst(CallInst *CI) {
223223
// Don't CSE convergent calls in different basic blocks, because they
224224
// implicitly depend on the set of threads that is currently executing.
225225
if (CI->isConvergent()) {
226-
return hash_combine(
227-
CI->getOpcode(), CI->getParent(),
228-
hash_combine_range(CI->value_op_begin(), CI->value_op_end()));
226+
return hash_combine(CI->getOpcode(), CI->getParent(),
227+
hash_combine_range(CI->operand_values()));
229228
}
230-
return hash_combine(
231-
CI->getOpcode(),
232-
hash_combine_range(CI->value_op_begin(), CI->value_op_end()));
229+
return hash_combine(CI->getOpcode(),
230+
hash_combine_range(CI->operand_values()));
233231
}
234232

235233
static unsigned getHashValueImpl(SimpleValue Val) {
@@ -302,12 +300,11 @@ static unsigned getHashValueImpl(SimpleValue Val) {
302300

303301
if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(Inst))
304302
return hash_combine(EVI->getOpcode(), EVI->getOperand(0),
305-
hash_combine_range(EVI->idx_begin(), EVI->idx_end()));
303+
hash_combine_range(EVI->indices()));
306304

307305
if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(Inst))
308306
return hash_combine(IVI->getOpcode(), IVI->getOperand(0),
309-
IVI->getOperand(1),
310-
hash_combine_range(IVI->idx_begin(), IVI->idx_end()));
307+
IVI->getOperand(1), hash_combine_range(IVI->indices()));
311308

312309
assert((isa<CallInst>(Inst) || isa<ExtractElementInst>(Inst) ||
313310
isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
@@ -322,7 +319,7 @@ static unsigned getHashValueImpl(SimpleValue Val) {
322319
std::swap(LHS, RHS);
323320
return hash_combine(
324321
II->getOpcode(), LHS, RHS,
325-
hash_combine_range(II->value_op_begin() + 2, II->value_op_end()));
322+
hash_combine_range(drop_begin(II->operand_values(), 2)));
326323
}
327324

328325
// gc.relocate is 'special' call: its second and third operands are
@@ -338,9 +335,8 @@ static unsigned getHashValueImpl(SimpleValue Val) {
338335
return hashCallInst(CI);
339336

340337
// Mix in the opcode.
341-
return hash_combine(
342-
Inst->getOpcode(),
343-
hash_combine_range(Inst->value_op_begin(), Inst->value_op_end()));
338+
return hash_combine(Inst->getOpcode(),
339+
hash_combine_range(Inst->operand_values()));
344340
}
345341

346342
unsigned DenseMapInfo<SimpleValue>::getHashValue(SimpleValue Val) {
@@ -608,9 +604,8 @@ unsigned DenseMapInfo<GEPValue>::getHashValue(const GEPValue &Val) {
608604
if (Val.ConstantOffset.has_value())
609605
return hash_combine(GEP->getOpcode(), GEP->getPointerOperand(),
610606
Val.ConstantOffset.value());
611-
return hash_combine(
612-
GEP->getOpcode(),
613-
hash_combine_range(GEP->value_op_begin(), GEP->value_op_end()));
607+
return hash_combine(GEP->getOpcode(),
608+
hash_combine_range(GEP->operand_values()));
614609
}
615610

616611
bool DenseMapInfo<GEPValue>::isEqual(const GEPValue &LHS, const GEPValue &RHS) {

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,9 +1445,9 @@ EliminateDuplicatePHINodesSetBasedImpl(BasicBlock *BB,
14451445
// Compute a hash value on the operands. Instcombine will likely have
14461446
// sorted them, which helps expose duplicates, but we have to check all
14471447
// the operands to be safe in case instcombine hasn't run.
1448-
return static_cast<unsigned>(hash_combine(
1449-
hash_combine_range(PN->value_op_begin(), PN->value_op_end()),
1450-
hash_combine_range(PN->block_begin(), PN->block_end())));
1448+
return static_cast<unsigned>(
1449+
hash_combine(hash_combine_range(PN->operand_values()),
1450+
hash_combine_range(PN->blocks())));
14511451
}
14521452

14531453
static unsigned getHashValue(PHINode *PN) {

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,8 +2734,8 @@ struct CSEDenseMapInfo {
27342734

27352735
static unsigned getHashValue(const Instruction *I) {
27362736
assert(canHandle(I) && "Unknown instruction!");
2737-
return hash_combine(I->getOpcode(), hash_combine_range(I->value_op_begin(),
2738-
I->value_op_end()));
2737+
return hash_combine(I->getOpcode(),
2738+
hash_combine_range(I->operand_values()));
27392739
}
27402740

27412741
static bool isEqual(const Instruction *LHS, const Instruction *RHS) {

0 commit comments

Comments
 (0)