This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Optimization of offset computations


On Mon, Nov 29, 1999 at 04:35:54PM +0000, Bernd Schmidt wrote:
> C standard question: is it legal to optimize
> 
>     unsigned int a = 65536;
>     unsigned int b;
> 
>     {
>          b = (a * 65536) / 8;
>     }
> 
> to
> 
>     unsigned int a = 65536;
>     unsigned int b;
> 
>     {
>          b = (a * 8192);
>     }

No.  Unsigned arithmetic has well-defined overflow.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]