lkml.org 
[lkml]   [2004]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: MSEC_TO_JIFFIES is messed up...
From
On Wed, May 12, 2004 at 02:01:58PM -0700, Davide Libenzi wrote:
> On Wed, 12 May 2004, Ingo Molnar wrote:
> > the compiler cannot discard the multiplication and the division from the
> > following:
> >
> > x * 1000 / 1000
> >
> > due to overflows.
>
> $ cat foo.c
>
> int foo(int i) {
>
>
> return i * 1000 / 1000;
> }

If gcc really optimizes that to just the identity function, then surely
that's a gcc bug? Multiplication is left-associative, so i * 1000 /
1000 = (i * 1000) / 1000, but (i * 1000) should be zero for any i
divisible by i^(sizeof(int) - 12).

It shouldn't be able to optimize out the 1000 here for exactly the same
reason it shouldn't be able to optimize out the shifts in, e.g.,

i << 12 >> 12

--Bruce Fields
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.264 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site