home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!orcenl!dk.oracle.com!bengsig
- From: bengsig@dk.oracle.com (Bjorn Engsig)
- Newsgroups: comp.unix.aix
- Subject: Re: optimisation and volatile
- Message-ID: <1993Jan12.105241.20359@dk.oracle.com>
- Date: 12 Jan 93 10:52:41 GMT
- References: <PHIL.93Jan7143750@lurch.dhcs.demon.co.uk>
- Sender: news@dk.oracle.com (News Administrator)
- Reply-To: bengsig@dk.oracle.com (Bjorn Engsig)
- Organization: Oracle Denmark
- Lines: 22
- Nntp-Posting-Host: dkaix1.dk.oracle.com
-
- Article <PHIL.93Jan7143750@lurch.dhcs.demon.co.uk> by phil@dhcs.demon.co.uk (phil) says:
- |would like to compile the code with -O optimization. The last time we tried
- |this the compiler would remove repeated shared memory reads with no intervening
- |writes,
- How should the compiler know that it needs to reload the data? We've had
- examples of the opposite: data are loaded even though they weren't needed,
- and if the data was in unallocated shared memory, you'd get a segmentation
- violation. E.g.: if(a) b++; may lay load b even if a is zero. Declaring
- b volatile avoids this [the actual code was more complicated than this].
-
- As you suggest yourself:
- |gcc has a switch `-fvolatile' : Consider all memory references through pointers
- |to be volatile.
- But why would you force all references to be considered volatile? The only
- resonable solution is to declare your volatile variables as volatile.
- |Is there an equivalent for xlc?
- Not that I know of.
- --
- Bjorn Engsig, Internet: bengsig@oracle.com uucp: uunet!oracle!bengsig
- ORACLE Corporation. Private : bjorn@login.dkuug.dk.
-
- Every program uses a constant amount of memory, if memory is counted in dollars.
-