This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Your sizetype changes ...
- To: geoffk at cygnus dot com
- Subject: Re: Your sizetype changes ...
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Wed, 1 Mar 00 12:48:38 EST
- Cc: gcc-patches at gcc dot gnu dot org
> No. The case is (x * 40) / 20. If x is a normal unsigned type, you
> can't convert this to x*2 because the x*40 might have overflowed. But
> if it's an actual sizetype, you can.
You mean, "if it's an actual size".
Not precisely. What I mean is if it's a computation in sizetype, bitsizetype,
or similar. Such computations are only made by the compiler and in a
way that overflow is undefined. So that optimization is safe.
In fact, it's not even always true that
sizeof(struct foo) * 40 / 20
is equivalent to
sizeof(struct foo) * 2
I didn't say it was and the code doesn't do that anymore.