This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Infinite number of iterations in loop [v850, mep]
- From: Paulo Matos <pmatos at broadcom dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Andrew Haley <aph at redhat dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Wed, 8 Jan 2014 15:43:28 +0000
- Subject: RE: Infinite number of iterations in loop [v850, mep]
- Authentication-results: sourceware.org; auth=none
- References: <19EB96622A777C4AB91610E763265F463A757B at SJEXCHMB14 dot corp dot ad dot broadcom dot com> <5283A108 dot 1020108 at redhat dot com> <19EB96622A777C4AB91610E763265F463A761A at SJEXCHMB14 dot corp dot ad dot broadcom dot com> <19EB96622A777C4AB91610E763265F463E5E93 at SJEXCHMB14 dot corp dot ad dot broadcom dot com> <CAFiYyc2ZzJFP0eYkZviZdt7YFxnFChRJNdwqsUs7T9=FmU-+xA at mail dot gmail dot com> <19EB96622A777C4AB91610E763265F463E7618 at SJEXCHMB14 dot corp dot ad dot broadcom dot com> <CAFiYyc3Fd4vBLQbMNH1RyvNGfUOcHS__FWeqYm89594Fjm6=LA at mail dot gmail dot com>
> -----Original Message-----
> From: Richard Biener [mailto:richard.guenther@gmail.com]
> Sent: 08 January 2014 14:42
> To: Paulo Matos
> Cc: Andrew Haley; gcc@gcc.gnu.org; Jan Hubicka
> Subject: Re: Infinite number of iterations in loop [v850, mep]
>
> Well. We have
>
> Loop 2 is simple:
> simple exit 5 -> 7
> infinite if: (expr_list:REG_DEP_TRUE (and:SI (reg:SI 76)
> (const_int 1 [0x1]))
> (nil))
> number of iterations: (lshiftrt:SI (plus:SI (minus:SI (reg:SI 68 [ D.1398 ])
> (reg:SI 64 [ ivtmp___6 ]))
> (const_int -2 [0xfffffffffffffffe]))
> (const_int 1 [0x1]))
> upper bound: 2147483646
> realistic bound: -1
> Doloop: Possible infinite iteration case.
> Doloop: The loop is not suitable.
>
> as we replaced the induction variable by a pointer induction with
> step 2. So this might be a very common issue for RTL loop opts,
> the upper bound of the IV is 2 * N in this case, so 2 * N & 1
> should be always false and thus "infinite" be optimized.
>
> (insn 34 33 36 3 (parallel [
> (set (reg:SI 76)
> (plus:SI (reg/v:SI 71 [ N ])
> (reg/v:SI 71 [ N ])))
> (clobber (reg:CC 32 psw))
> ]) 21 {addsi3}
> (expr_list:REG_UNUSED (reg:CC 32 psw)
> (nil)))
>
> that doesn't look too difficult to do with the above definition.
> nonzero_bits might be of use here, not sure (not my area of
> expertise).
>
You're right. After having had a look at the code this looks like something to be added to simplify_using_initial_values.
I will try to patch it up and will post it upstream once complete for comments.
Thanks,
--
Paulo Matos