This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: potential simple loop optimization assistance strategy?
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Giovanni Bajo <rasky at develer dot com>
- Cc: Paul Schlie <schlie at comcast dot net>, gcc at gcc dot gnu dot org
- Date: Fri, 1 Jul 2005 14:22:01 -0400
- Subject: Re: potential simple loop optimization assistance strategy?
- References: <BEEADEA6.AB11%schlie@comcast.net> <029601c57e68$fa76b7b0$bf03030a@trilan>
On Fri, Jul 01, 2005 at 08:16:19PM +0200, Giovanni Bajo wrote:
> Paul Schlie <schlie@comcast.net> wrote:
>
> > Where then the programmer could then choose
> > to warrant it by preconditioning the loop:
> >
> > assert((x < y) && ((y - x) % 4)); // which could throw an exception.
> >
> > for ((i = x; i < y; i++){ ... }
>
> There has been some opposition in the past about allowing conditions in
> asserts to be used as hints to the optimizers. In fact, I would like to know
> if there is a current statement of purpose about this. That is, would there
> be strong oppositions to patches doing this?
>
VRP naturally takes advantage of assert (though not in some
occassions involving unsigned types). Try:
#include <assert.h>
foo (int i)
{
assert (i != 0);
if (i == 0)
return 3;
return 2;
}
Diego.