On Fri, 7 Oct 2016, Bernd Schmidt wrote: > On 10/07/2016 01:07 PM, Richard Biener wrote: > > On Fri, 7 Oct 2016, Bernd Schmidt wrote: > > > > > Here, if necessary I'd prefer we create a to_clear bitmap and perform an > > > and_compl operation after the loop. > > > > But that's way more expensive -- you allocate memory and perform an > > additional loop over the bitmap. > > Yeah. Can we have an additional safer variant of the bitmap iterators maybe? > We could have an object that gets constructed in the for statement and serves > as a lock/unlock, where we postpone deletion of elements while locked, and > flush them on unlock (keeping a flag to say if that's necessary).
I think what might work is implementing that single-depth-queue inside the iterator, thus have a bitmap_clear_bit_at_iterator (bitmap_iterator *, int which = 0); (which == 1 for when you use EXECUTE_IF_AND_IN_BITMAP and want to clear a bit in the second bitmap). The clearing would need to be done in bmp_iter_set_* in a safe way and the above function would simply set a flag in the bitmap_iterator. I think it will be a non-trivial task still. Any such interface needs to be carried over to other bitmap users (like the regset case). Richard.