On June 12, 2020 2:55:49 PM GMT+02:00, "Martin Liška" <mli...@suse.cz> wrote:
>On 6/12/20 1:43 PM, Richard Sandiford wrote:
>> 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).
>
>Ah, ok, I've got it.
>
>> 
>> In other words, the function (rightly) implements “++it” rather than
>“it++”.
>> 
>> With that fixed, it seems like a range-based for loop should work.
>
>Yes, it works. The syntax is really neat:
>
>for (gimple *stmt: *bb_vinfo)

I'd rather have what we iterate over more explicit like

For(gimple. *stmt : bb_vinfo->region_stmts()) 

Richard. 

>
>I've tested vect.exp and i386.exp. May I install the patch after proper
>testing?
>
>Thanks,
>Martin
>
>> 
>> Thanks,
>> Richard
>> 

Reply via email to