On Mar 10, 2016 1:21 PM, "Eirik Byrkjeflot Anonsen" <ei...@eirikba.org>
wrote:
>
> Ian Romanick <i...@freedesktop.org> writes:
>
> > From: Ian Romanick <ian.d.roman...@intel.com>
> >
> > I don't understand why the old code was bad, but the new code is fine.
>
> Probably because the *loop counter* can no longer overflow. Thus the
> loop can be optimized. The fact that "i" might overflow has become
> irrelevant to the warning.

Right.  In theory, since i is incremented by 4 each time it could, in
theory, skip right over size/4 and overflow.  However, this can never
happen since size is 32 bits and is divided by 4 so it has a maximum value
of 2^30-1.  Apparently, GCC isn't quite that smart. :-)

> (And from that perspective, it isn't equivalent. If "i" overflows in the
> original code, you would get an infinite loop.)
>
> eirik
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to