This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
- From: Trevor Saunders <tbsaunde at tbsaunde dot org>
- To: Bernd Schmidt <bschmidt at redhat dot com>
- Cc: tbsaunde+gcc at tbsaunde dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 Apr 2016 09:30:26 -0400
- Subject: Re: [PATCH 07/18] loop-iv.c: make cond_list a vec
- Authentication-results: sourceware.org; auth=none
- References: <1461133342-10794-1-git-send-email-tbsaunde+gcc at tbsaunde dot org> <1461133342-10794-8-git-send-email-tbsaunde+gcc at tbsaunde dot org> <571E0D83 dot 8070305 at redhat dot com>
On Mon, Apr 25, 2016 at 02:28:51PM +0200, Bernd Schmidt wrote:
> On 04/20/2016 08:22 AM, tbsaunde+gcc@tbsaunde.org wrote:
> >From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> >+ unsigned int len = cond_list.length ();
> >+ for (unsigned int i = len - 1; i < len; i--)
>
> This is a really icky way to write a loop, the i < len condition makes it
> look like a forward one. We have FOR_EACH_VEC_ELT{,_REVERSE}, any reason not
> to use these?
I'll agree that depending on unsigned wrapping is a tad wierd, but
personally I think FOR_EACH_VEC_* are pretty icky, and just forget to
think about them before writing a loop. The vec::iterate () methods are
a little slower than they need to be since they check the vector length
each iteration instead of caching it (and pretty sure the compiler can't
save you in a bunch of these places). Its Unfortunate you need to
declare a temporary for the vector item, and worse that temporary can't
be scoped by the loop. Finally it seems like more work to remember
the order of arguments to FOR_EACH_VEC_ than just to write the loop.
That all said if people really feel strongly and I'll grant consistancy
matters I can try and change loops to use FOR_EACH_VEC_*.
Trev
>
>
> Bernd