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


    >     >     unsigned int a = 65536;
    >     >          b = (a * 65536) / 8;
    >     >          b = (a * 8192);
    > 
    > Sure, but don't both expressions overflow the same way?

    Absolutely not.

    To 32 bits, the first is 0x1_0000_0000 = 0 / 8 = 0,
    whereas the second is 0x2000_0000.

Oops! Of course ...

I'm not sure what to do here.  sizetype is normally unsigned, so
restricting this optimization to signed isn't useful.  And these are
quite important optimizations for size computations.

Does anybody have any ideas?


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