diff options
author | Kazu Hirata <kazu@google.com> | 2025-03-23 19:42:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-23 19:42:53 -0700 |
commit | 73dc2afd2c334aac735caba94292052d63014c9d (patch) | |
tree | 129d75db3156ceb1920e458f5ea913f2a53df27d /llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp | |
parent | 943a70717c629f43b309ab56e8141ffb131871a6 (diff) | |
download | llvm-73dc2afd2c334aac735caba94292052d63014c9d.zip llvm-73dc2afd2c334aac735caba94292052d63014c9d.tar.gz llvm-73dc2afd2c334aac735caba94292052d63014c9d.tar.bz2 |
[Transforms] Use *Set::insert_range (NFC) (#132652)
We can use *Set::insert_range to collapse:
for (auto Elem : Range)
Set.insert(E);
down to:
Set.insert_range(Range);
In some cases, we can further fold that into the set declaration.
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index 0b35ff8..c14bbec 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -881,11 +881,8 @@ void CHR::checkScopeHoistable(CHRScope *Scope) { // Avoid a data dependence from a select or a branch to a(nother) // select. Note no instruction can't data-depend on a branch (a branch // instruction doesn't produce a value). - DenseSet<Instruction *> Unhoistables; // Initialize Unhoistables with the selects. - for (SelectInst *SI : Selects) { - Unhoistables.insert(SI); - } + DenseSet<Instruction *> Unhoistables(llvm::from_range, Selects); // Remove Selects that can't be hoisted. for (auto it = Selects.begin(); it != Selects.end(); ) { SelectInst *SI = *it; @@ -1104,8 +1101,7 @@ static bool shouldSplit(Instruction *InsertPoint, static void getSelectsInScope(CHRScope *Scope, DenseSet<Instruction *> &Output) { for (RegInfo &RI : Scope->RegInfos) - for (SelectInst *SI : RI.Selects) - Output.insert(SI); + Output.insert_range(RI.Selects); for (CHRScope *Sub : Scope->Subs) getSelectsInScope(Sub, Output); } @@ -1370,11 +1366,8 @@ void CHR::setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope) { // Put the biased selects in Unhoistables because they should stay where they // are and constant-folded after CHR (in case one biased select or a branch // can depend on another biased select.) - for (RegInfo &RI : Scope->RegInfos) { - for (SelectInst *SI : RI.Selects) { - Unhoistables.insert(SI); - } - } + for (RegInfo &RI : Scope->RegInfos) + Unhoistables.insert_range(RI.Selects); Instruction *InsertPoint = OutermostScope->BranchInsertPoint; for (RegInfo &RI : Scope->RegInfos) { Region *R = RI.R; |