[Mesa-dev] [PATCH 03/10] i965: Silence loop counter overflow warning

Jason Ekstrand jason at jlekstrand.net
Fri Mar 11 06:38:20 UTC 2016


On Mar 10, 2016 1:21 PM, "Eirik Byrkjeflot Anonsen" <eirik at eirikba.org>
wrote:
>
> Ian Romanick <idr at freedesktop.org> writes:
>
> > From: Ian Romanick <ian.d.romanick at 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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160310/cfaf0640/attachment-0001.html>


More information about the mesa-dev mailing list