This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH GCC8][32/33]Save niter check for vect peeling if loop versioning is required


On Sat, Jun 10, 2017 at 11:06 AM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> Another one sorry, but:
>
> Bin Cheng <Bin.Cheng@arm.com> writes:
>> diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
>> index af874e7..98caa5e 100644
>> --- a/gcc/tree-vect-loop.c
>> +++ b/gcc/tree-vect-loop.c
>> @@ -2214,6 +2214,36 @@ start_over:
>>          }
>>      }
>>
>> +  /* During peeling, we need to check if number of loop iterations is
>> +     enough for both peeled prolog loop and vector loop.  This check
>> +     can be merged along with threshold check of loop versioning, so
>> +     increase threshold for this case if necessary.  */
>> +  if (LOOP_REQUIRES_VERSIONING (loop_vinfo)
>> +      && (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
>> +       || LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo)))
>> +    {
>> +      unsigned niters_th;
>> +
>> +      /* Niters for peeled prolog loop.  */
>> +      if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0)
>> +     {
>> +       struct data_reference *dr = LOOP_VINFO_UNALIGNED_DR (loop_vinfo);
>> +       tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (DR_STMT (dr)));
>> +
>> +       niters_th = TYPE_VECTOR_SUBPARTS (vectype) - 1;
>> +     }
>> +      else
>> +     niters_th = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
>> +
>> +      /* Niters for at least one iteration of vectorized loop.  */
>> +      niters_th += LOOP_VINFO_VECT_FACTOR (loop_vinfo);
>> +      /* One additional iteration because of peeling for gap.  */
>> +      if (!LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
>> +     niters_th++;
>
> is the ! intentional here?  It looks like it should adding 1 when
> peeling for gaps _is_ needed.
Hi Richard,
Thanks for spotting this.  This one is more like my typo.  The
comments says one additional iteration for peeling gap, but the code
does the opposite.  How to fix this depends on the answer to previous
question.  If th stands for minimum niters of vector loop, we need:
>> +      /* One additional iteration because of peeling for gap.  */
>> +      if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
>> +     niters_th++;

If it stands for maximum niters of scalar loop, we need:
>> +      /* One additional iteration because of peeling for gap.  */
>> +      if (!LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
>> +     niters_th--;


Thanks,
bin

>
>> +      if (LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo) < niters_th)
>> +     LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo) = niters_th;
>> +    }
>> +
>>    gcc_assert (vectorization_factor
>>             == (unsigned)LOOP_VINFO_VECT_FACTOR (loop_vinfo));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]