@@ -1521,8 +1521,8 @@ class EliminateInterleaves : public IRMutator {
15211521 }
15221522
15231523 if (const Load *load = x.as <Load>()) {
1524- if (buffers.contains (load->name )) {
1525- BufferState &state = buffers. ref (load-> name ) ;
1524+ if (auto *state_ptr = buffers.shallow_find (load->name )) {
1525+ BufferState &state = *state_ptr ;
15261526 if (state != BufferState::NotInterleaved) {
15271527 state = BufferState::Interleaved;
15281528 return x;
@@ -1814,23 +1814,27 @@ class EliminateInterleaves : public IRMutator {
18141814 op->func , op->value_index , op->image , op->param );
18151815 // Add the interleave back to the result of the call.
18161816 return native_interleave (expr);
1817- } else if (deinterleaving_alts.find (op->name ) != deinterleaving_alts.end () && hvx_target >= deinterleaving_alts[op->name ].first &&
1818-
1817+ } else if (auto it = deinterleaving_alts.find (op->name );
1818+ it != deinterleaving_alts.end () &&
1819+ hvx_target >= it->second .first &&
18191820 yields_removable_interleave (args)) {
18201821 // This call has a deinterleaving alternative, and the
18211822 // arguments are interleaved, so we should use the
18221823 // alternative instead.
18231824 for (Expr &i : args) {
18241825 i = remove_interleave (i);
18251826 }
1826- return Call::make (op->type , deinterleaving_alts[op->name ].second , args, op->call_type );
1827- } else if (interleaving_alts.count (op->name ) && hvx_target >= interleaving_alts[op->name ].first && is_native_deinterleave (args[0 ])) {
1827+ return Call::make (op->type , it->second .second , args, op->call_type );
1828+ } else if (auto it = interleaving_alts.find (op->name );
1829+ it != interleaving_alts.end () &&
1830+ hvx_target >= it->second .first &&
1831+ is_native_deinterleave (args[0 ])) {
18281832 // This is an interleaving alternative with a
18291833 // deinterleave, which can be generated when we
18301834 // deinterleave storage. Revert back to the interleaving
18311835 // op so we can remove the deinterleave.
18321836 Expr arg = args[0 ].as <Call>()->args [0 ];
1833- return Call::make (op->type , interleaving_alts[op-> name ] .second , {arg}, op->call_type ,
1837+ return Call::make (op->type , it-> second .second , {arg}, op->call_type ,
18341838 op->func , op->value_index , op->image , op->param );
18351839 } else if (changed) {
18361840 return Call::make (op->type , op->name , args, op->call_type ,
@@ -1937,7 +1941,7 @@ class EliminateInterleaves : public IRMutator {
19371941 }
19381942
19391943 Expr visit (const Load *op) override {
1940- if (buffers.contains (op->name )) {
1944+ if (auto *buf_state = buffers.shallow_find (op->name )) {
19411945 if ((op->type .lanes () * op->type .bits ()) % (native_vector_bits * 2 ) == 0 ) {
19421946 // This is a double vector load, we might be able to
19431947 // deinterleave the storage of this buffer.
@@ -1959,8 +1963,7 @@ class EliminateInterleaves : public IRMutator {
19591963 } else {
19601964 // This is not a double vector load, so we can't
19611965 // deinterleave the storage of this buffer.
1962- BufferState &state = buffers.ref (op->name );
1963- state = BufferState::NotInterleaved;
1966+ *buf_state = BufferState::NotInterleaved;
19641967 }
19651968 }
19661969 Expr expr = IRMutator::visit (op);
@@ -2224,16 +2227,18 @@ class SyncronizationBarriers : public IRMutator {
22242227 // Creates entry in sync map for the stmt requiring a
22252228 // scatter-release instruction before it.
22262229 void check_hazard (const string &name) {
2227- if (in_flight.find (name) == in_flight.end ()) {
2230+ auto it = in_flight.find (name);
2231+ if (it == in_flight.end ()) {
22282232 return ;
22292233 }
22302234 // Sync Needed. Add the scatter-release before the first different For
22312235 // loop lock between the curr_path and the hazard src location.
2232- size_t min_size = std::min (in_flight[name].size (), curr_path.size ());
2236+ const auto &flight_path = it->second ;
2237+ size_t min_size = std::min (flight_path.size (), curr_path.size ());
22332238 size_t i = 0 ;
22342239 // Find the first different For loop block.
22352240 for (; i < min_size; i++) {
2236- if (in_flight[name] [i] != curr_path[i]) {
2241+ if (flight_path [i] != curr_path[i]) {
22372242 break ;
22382243 }
22392244 }
@@ -2266,9 +2271,9 @@ class SyncronizationBarriers : public IRMutator {
22662271 curr = &s;
22672272 Stmt new_s = IRMutator::mutate (s);
22682273 // Wrap the stmt with scatter-release if any hazard was detected.
2269- if (sync.find (&s) != sync.end ()) {
2274+ if (auto it = sync.find (&s); it != sync.end ()) {
22702275 Stmt scatter_sync =
2271- Evaluate::make (Call::make (Int (32 ), Call::hvx_scatter_release, {sync[&s] }, Call::Intrinsic));
2276+ Evaluate::make (Call::make (Int (32 ), Call::hvx_scatter_release, {it-> second }, Call::Intrinsic));
22722277 return Block::make (scatter_sync, new_s);
22732278 }
22742279 return new_s;
0 commit comments