This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Worth balancing the tree before scheduling?
On Wed, Nov 25, 2009 at 2:52 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> Hello,
> It seems to me that tree balancing risk of producing wrong result due
> to overflow of subexpression.
>
> Say a = INT_MIN, b = 10, c = 10, d = INT_MAX.
>
> If
> ((a + b) + c) + d))
>
> becomes
> ((a + b) + (c + d))
>
> c + d will overflow and the original won't. So the behaviour of
> two are different. Though the architecture may manage to produce
> correct result, it is undefined I think.
We only associate usigned arithmetic for exactly this reason.
Richard.