From: Kyle Moffett <mrmacman_g4@mac.com>
To: davids@webmaster.com
Cc: "Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
schwab@suse.de
Subject: Re: [patch 2.6.19-rc6] Stop gcc 4.1.0 optimizing wait_hpet_tick away
Date: Thu, 7 Dec 2006 09:02:36 -0500 [thread overview]
Message-ID: <A1480C13-162B-4593-A378-05FE43D1D0D2@mac.com> (raw)
In-Reply-To: <MDEHLPKNGKAHNMBLJOLKKEMLABAC.davids@webmaster.com>
My apologies for the late response, I've had a lot on my schedule
over the last week.
On Dec 02, 2006, at 23:29:28, David Schwartz wrote:
>>> It comes down to just what those guarantees GCC provides actually
>>> are.
>
>> This is the first correct statement in your email. In any case
>> the documented GCC guarantees have always been much stronger than
>> you have been trying to persuade us they should be. I would argue
>> that the C standard somewhat indirectly specifies those guarantees
>> but I really don't have the heart for any more language-lawyering
>> so I'm going to leave it at that.
>
> I have tried to find any documentation of the guarantees gcc
> actually provides and have been unable to do so. Where are these
> "documented GCC guarantees" documented?
Well, under "When is a Volatile Object Accessed" in the GCC manual
(seems to be present for at least a few versions back):
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Volatiles.html#Volatiles
In that case it specifies that any evaluation of "*foo" in an rvalue
context specifies a read (with a few exceptions for G++ where the C++
language generally confuses things). Specifically it mentions the
statement "*src;" and discusses the statement as providing "a void
context". In other words, a statement such as "(void)(expr);" is
redundant because the statement already implies void context and the
extra cast-to-void is just extra text. As such "(void)(*src);" on a
"volatile int *src;" is documented to force a read of "*src". Now,
if you actually _use_ the result over just casting it to void and
discarding it, then GCC can provide no _less_ guarantee with regards
to the read-and-store than it provides to the read-and-discard.
For example:
/* This code is guaranteed to generate assembly to read the memory
address into a register multiple times */
volatile int *foo = (expression);
*foo;
*foo;
/* This code is guaranteed to do the same */
volatile int *foo = (expression);
int x, y;
x = *foo;
y = *foo;
If the result is actually the conditional expression for a loop as in
the problem code then GCC would plainly have no choice about
optimizing, not only is the volatile variable read and returned, but
the result is the conditional for continued execution of a block of
code with unknown side effects.
Cheers,
Kyle Moffett
next prev parent reply other threads:[~2006-12-07 14:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-29 2:22 Keith Owens
2006-11-29 3:08 ` Nicholas Miell
2006-11-29 3:56 ` Keith Owens
2006-11-29 4:04 ` David Miller
2006-11-29 4:30 ` Keith Owens
2006-11-29 4:57 ` Nicholas Miell
2006-11-30 1:04 ` David Schwartz
2006-12-01 5:50 ` Kyle Moffett
2006-12-01 11:24 ` David Schwartz
2006-12-01 12:08 ` Kyle Moffett
2006-12-01 13:52 ` David Schwartz
2006-12-02 9:02 ` Jan Engelhardt
2006-12-01 12:31 ` Andreas Schwab
2006-12-01 14:03 ` David Schwartz
2006-12-02 10:39 ` Kyle Moffett
2006-12-03 4:29 ` David Schwartz
2006-12-07 14:02 ` Kyle Moffett [this message]
2006-12-08 4:22 ` David Schwartz
2006-11-29 9:08 ` Jakub Jelinek
2006-11-29 20:14 ` Willy Tarreau
2006-12-01 5:05 ` Andrew Morton
2006-12-01 5:14 ` Keith Owens
2006-12-01 5:26 ` Willy Tarreau
2006-12-01 6:32 ` Keith Owens
2006-12-01 7:28 ` Willy Tarreau
2006-12-01 7:57 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A1480C13-162B-4593-A378-05FE43D1D0D2@mac.com \
--to=mrmacman_g4@mac.com \
--cc=davids@webmaster.com \
--cc=linux-kernel@vger.kernel.org \
--cc=schwab@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®