On Mon, May 14, 2012 at 4:26 AM, Geert Bosch <bo...@adacore.com> wrote:
>
> On May 13, 2012, at 21:17, amyl...@spamcop.net wrote:
>> The expectation is wrap-around.  Note that loop strenght reduction can
>> cause assumed wrap-around semantics in RTL for strictly conforming C input
>> where no such wrap-around is in evidence.
>
> Really, we should define signed integer arithmetic in RTL to always
> be wrap-around. While there may (*) be some benefit in "taking
> advantage" of undefined semantics of integer overflow in early tree
> optimizers (computing number of loop iterations etc.), at the same
> time it also reduces optimization opportunities.
>
> Transformations cannot introduce overflows where none existed before,
> so integer addition and subtraction are not associative.  In the
> end, the hardware is deterministic and does have wrap-around
> semantics. So, it really doesn't make sense to pretend in RTL that
> it doesn't.

I agree - but we don't have signed vs. unsigned PLUS on RTL so RTL
arith is unsigned anway, no?

Richard.

>  -Geert
>
> --
> (*) At the end of the day, I think everybody would win by unambiguously
> defining signed integer arithmetic as using wrap-around semantics
> everywhere. Software is hard enough with defined semantics.
>

Reply via email to