public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bill Currie <bcurrie@tssc.co.nz>
To: law@cygnus.com
Cc: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>,
	Horst von Brand <vonbrand@inf.utfsm.cl>,
	Matthias Urlichs <smurf@noris.de>,
	egcs@cygnus.com
Subject: Re: Incrementing volatiles?
Date: Wed, 15 Jul 1998 17:22:00 -0000	[thread overview]
Message-ID: <35AD22FF.7436@tssc.co.nz> (raw)
In-Reply-To: <19384.900492209@hurl.cygnus.com>

Jeffrey A Law wrote:
> But you can not increment without first reading its value.

However, if the CPU supports `atomic' increments (most if not all CISC
cpus), then it should be used.

> Note, that we are not going to change the meaning of volatile, so debating
> this point probably isn't worth the time.

Hmm, I seem to have been mis-understood.  I was not proposing a change
to the meaning of volatile.  What I was saying is that new RTXs should
be created for the increment and friends orperators.

Ouch I just realised why I was probably misunderstood.  I mean
insn-patterns, not RTXs.  In fact, I don't think new RTXs would be
needed.  Maybe an example would help (i386):

(define_expand "incsi"
  [(set (match_operand:SI 0 "nonimmediate_operand" "")
        (plus:SI (match_dup 0)
                 (match_dup 1)))]
  ""
  "
{
  operands[1] = const1_rtx;
}")

(define_insn ""
  [(set (match_operand:SI 0 "nonimmediate_operand" "rm")
        (plus:SI (match_dup 0)
                 (match_operand:SI 1 "const1_operand" "")))]
  ""
  "* return AS1(inc%L0,%0);")

[NOTE: const1_operand may be bogus, I just picked a name out of the hat]

For cpus that don't support this, "incsi" can expand into the old
sequence.

Now, (AIUI) no matter what optimisation level is used, the increment
instruction will be used thus preserving the meaning of volatile to the
limits of the CPU.  Anyway, it's faster (and smaller) than an explicit
read/modify/write.

Unless I misunderstood some of the previous arguments, this is really a
win-win situations.  Yes, I know, there's still the problem of getting
the compiler to USE `incsi' and the others, but it could be worth it in
the long run (I don't think cpu's with `inc' instructions are going to
disappear anytime soon).

Bill
-- 
Leave others their otherness

  reply	other threads:[~1998-07-15 17:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-08 14:20 Matthias Urlichs
1998-07-10  6:04 ` Andreas Schwab
1998-07-10 21:04   ` John Vickers
1998-07-13  2:36     ` Philippe De Muyter
1998-07-13  2:40       ` Andreas Schwab
1998-07-13  4:36         ` Philippe De Muyter
1998-07-13  8:48       ` Joe Buck
1998-07-15  6:45         ` Andi Kleen
1998-07-13 12:40       ` Franz Sirl
1998-07-11  6:03   ` Horst von Brand
1998-07-13  1:48     ` Andreas Schwab
1998-07-14 18:59       ` Bill Currie
1998-07-15  1:49         ` Jeffrey A Law
1998-07-15 17:22           ` Bill Currie [this message]
1998-07-15 17:22             ` Jeffrey A Law
1998-07-15 17:56               ` Bill Currie
1998-07-15 17:22                 ` Jeffrey A Law
1998-07-15 17:34                 ` Matthias Urlichs
1998-07-15 21:58                   ` Bill Currie
1998-07-16 11:28                   ` Carlo Wood
1998-07-17  4:06                 ` Andreas Schwab
1998-07-15  3:14         ` Joern Rennecke
1998-07-15  3:14         ` Andreas Schwab
1998-07-15 17:22           ` Carlo Wood
1998-07-17  4:10             ` Andreas Schwab
     [not found] <egcs.199807111302.JAA10664@pincoya.inf.utfsm.cl>
1998-07-13  0:06 ` Todd P. Whitesel
1998-07-17  8:59 Mike Stump

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=35AD22FF.7436@tssc.co.nz \
    --to=bcurrie@tssc.co.nz \
    --cc=egcs@cygnus.com \
    --cc=law@cygnus.com \
    --cc=schwab@issan.informatik.uni-dortmund.de \
    --cc=smurf@noris.de \
    --cc=vonbrand@inf.utfsm.cl \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).