Martin Liška <mli...@suse.cz> writes: > On 6/12/20 12:46 PM, Richard Sandiford wrote: >> Martin Liška <mli...@suse.cz> writes: >>> Hello. >>> >>> I'm working one extension of SLP which will allow to vectorize multiple >>> BBs. This is a first step where I abstract _bb_vec_info::region_begin and >>> _bb_vec_info::region end by providing an iterator. >> >> Nice. >> >>> diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h >>> index 6c830ad09f4..542d49402d2 100644 >>> --- a/gcc/tree-vectorizer.h >>> +++ b/gcc/tree-vectorizer.h >>> @@ -787,12 +787,46 @@ loop_vec_info_for_loop (class loop *loop) >>> typedef class _bb_vec_info : public vec_info >>> { >>> public: >>> + struct const_iterator >>> + { >>> + const_iterator (gimple_stmt_iterator _gsi): gsi (_gsi) >>> + { >>> + } >>> + >>> + const_iterator & >>> + operator++ (int) >>> + { >>> + gsi_next (&gsi); return *this; >>> + } >> >> Isn't this really operator++()? > > It is, but post-increment ++ operators have one integer argument (so that > one can distinguish them from pre-increment operators: > https://en.cppreference.com/w/cpp/language/operator_incdec)
Sure, but what I mean by: >> I.e. it returns a reference to the >> modified iterator instead of the value at the original iterator. is that the above implements the semantics of a preincrement, not a postincrement, so it should be operator++() rather than operator++(int). In other words, the function (rightly) implements “++it” rather than “it++”. With that fixed, it seems like a range-based for loop should work. Thanks, Richard