This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] for PR 17531
On Tue, Sep 28, 2004 at 02:44:33AM +0200, Zdenek Dvorak wrote:
> is it really necessary to use this tone? I spent a second thinking and
> observed that if you were right, the optimization would either not work
> at all or consistently cause misscompilations on LP64 platforms. Which
> it does not.
My guess is that the extra conversions increase the cost a bit,
which presumably arranges for us to not choose this variant.
Which is extra work that might be avoided, as well as actively
rather than accidentally avoiding generating incorrect code.
> for (p = &a; p < &a + 200B; p += 2B)
> *p = (short) (p - &a);
>
> is perfectly valid.
Sure, but
*p = (short)((short)p - (short) &a)
isn't. So any time you find yourself truncating a pointer rather
than an integer you should fail the operation.
r~