| To: | Davide Libenzi <davidel@xxxxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: MSEC_TO_JIFFIES is messed up... |
| From: | "J. Bruce Fields" <bfields@xxxxxxxxxxxx> |
| Date: | Wed, 12 May 2004 17:39:13 -0400 |
| Cc: | Ingo Molnar <mingo@xxxxxxx>, Jeff Garzik <jgarzik@xxxxxxxxx>, Greg KH <greg@xxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Netdev <netdev@xxxxxxxxxxx> |
| In-reply-to: | <Pine.LNX.4.58.0405121400360.11950@xxxxxxxxxxxxxxxxxxxxxxx> |
| References: | <20040512020700.6f6aa61f.akpm@xxxxxxxx> <20040512181903.GG13421@xxxxxxxxx> <40A26FFA.4030701@xxxxxxxxx> <20040512193349.GA14936@xxxxxxx> <Pine.LNX.4.58.0405121247011.11950@xxxxxxxxxxxxxxxxxxxxxxx> <20040512200305.GA16078@xxxxxxx> <Pine.LNX.4.58.0405121400360.11950@xxxxxxxxxxxxxxxxxxxxxxx> |
| Sender: | netdev-bounce@xxxxxxxxxxx |
| User-agent: | Mutt/1.5.6i |
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
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: MSEC_TO_JIFFIES is messed up..., Ingo Molnar |
|---|---|
| Next by Date: | Re: MSEC_TO_JIFFIES is messed up..., Davide Libenzi |
| Previous by Thread: | Re: MSEC_TO_JIFFIES is messed up..., Zan Lynx |
| Next by Thread: | Re: MSEC_TO_JIFFIES is messed up..., Andreas Schwab |
| Indexes: | [Date] [Thread] [Top] [All Lists] |