This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix PR48052: loop not vectorized if index is "unsigned int"
- From: "Bin.Cheng" <amker dot cheng at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jeff Law <law at redhat dot com>, Bingfeng Mei <bmei at broadcom dot com>, Aditya K <hiraditya at msn dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "a dot zaafrani at samsung dot com" <a dot zaafrani at samsung dot com>, "sebpop at gmail dot com" <sebpop at gmail dot com>
- Date: Mon, 1 Jun 2015 16:15:13 +0800
- Subject: Re: Fix PR48052: loop not vectorized if index is "unsigned int"
- Authentication-results: sourceware.org; auth=none
- References: <BLU179-W94C54A046BE24828966E26B6C30 at phx dot gbl> <55694EF6 dot 6040109 at redhat dot com> <CAFiYyc2FQDqnkHf=7xHGdNW7Q8DMoRKXQEmieYKK53BB_3F35Q at mail dot gmail dot com>
On Mon, Jun 1, 2015 at 4:00 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Sat, May 30, 2015 at 7:47 AM, Jeff Law <law@redhat.com> wrote:
>> On 05/19/2015 10:12 AM, Aditya K wrote:
>>>
>>> w.r.t. the PR48052, here is the patch which finds out if scev would wrap
>>> or not.
>>> The patch symbolically evaluates if valid_niter>= loop->nb_iterations is
>>> true. In that case the scev would not wrap (??).
>>> Currently, we only look for two special 'patterns', which are sufficient
>>> to analyze the simple test cases.
>>>
>>> valid_niter = ~s (= UNIT_MAX - s)
>>> We have to prove that valid_niter>= loop->nb_iterations
>>>
>>> Pattern1 loop->nb_iterations: s>= e ? s - e : 0
>>> Pattern2 loop->nb_iterations: (e - s) -1
>>>
>>> In the first case we prove that valid_niter>= loop->nb_iterations in both
>>> the cases i.e., when s>=e and when not.
>>> In the second case we prove valid_niter>= loop->nb_iterations, by simple
>>> analysis that UINT_MAX>= e is true in all cases.
>>>
>>> I haven't tested this patch completely. I'm looking for feedback and any
>>> scope for improvement.
>>>
>>>
>>> hth,
>>> -Aditya
>>>
>>>
>>>
>>> Vectorize loops which has typecast.
>>>
>>> 2015-05-19 hiraditya <hiraditya@msn.com>
>>>
>>> * gcc.dg/vect/pr48052.c: New test.
>>>
>>> gcc/ChangeLog:
>>>
>>> 2015-05-19 hiraditya <hiraditya@msn.com>
>>>
>>> * tree-ssa-loop-niter.c (fold_binary_cond_p): Fold a conditional
>>> operation when additional constraints are
>>> available.
>>> (fold_binary_minus_p): Fold a subtraction operations of the form
>>> (A - B -1) when additional constraints are
>>> available.
>>> (scev_probably_wraps_p): Use the above two functions to find
>>> whether valid_niter>= loop->nb_iterations.
>>
>> Is any of this work still useful if Bin Cheng's work on improving overflow
>> detection for scev goes forward? I certainly got the impression that Bin's
>> work would solve 48052 and others.
>
> Bin is probably the one to answer this. His patches are still on my list
> of patches to review...
Richard, you have already approved the first one. The second one is
at https://gcc.gnu.org/ml/gcc-patches/2015-05/msg02317.html . You may
need to decide if it is as expected.
Yes, PRs like 62173, 52563 and 48052 will be fixed with these two patches.
Thanks,
bin
>
> Richard.
>
>> Jeff
>>