public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* aliasing
@ 1999-08-21  9:23 Jason Moxham
  1999-08-21  9:46 ` aliasing Mark Mitchell
  1999-08-31 23:20 ` aliasing Jason Moxham
  0 siblings, 2 replies; 19+ messages in thread
From: Jason Moxham @ 1999-08-21  9:23 UTC (permalink / raw)
  To: gcc

I have a C++ ( really a C prog with a couple of overloaded fn's )
program which I'm fairly sure breaks the strict aliasing rules of
Gcc-2.95.1 

Where can find a copy of what these rules are , so I can fix my code ?


For a temporary fix I added -fno-strict-aliasing to the options and
expected a performance drop . However the program now runs 1% faster ???
(I assure you 1% is not a trival amount)

Using Slackware 3.9 + gcc 2.95.1 on AMD K6(x86)
options -O3 -fno-exceptions -funroll-loops -march=k6
-fomit-frame-pointer -ffast-math   ... etc

I can send 
source(100K) + exe's(50K) + data  etc.. 


Jason Moxham
jlm@maths.soton.ac.uk

^ permalink raw reply	[flat|nested] 19+ messages in thread
* aliasing
@ 2024-03-18  7:03 Martin Uecker
  2024-03-18  8:26 ` aliasing Richard Biener
  2024-03-18  9:00 ` aliasing David Brown
  0 siblings, 2 replies; 19+ messages in thread
From: Martin Uecker @ 2024-03-18  7:03 UTC (permalink / raw)
  To: gcc; +Cc: Richard Biener


Hi,

can you please take a quick look at this? This is intended to align
the C standard with existing practice with respect to aliasing by
removing the special rules for "objects with no declared type" and
making it fully symmetric and only based on types with non-atomic
character types being able to alias everything.


Unrelated to this change, I have another question:  I wonder if GCC
(or any other compiler) actually exploits the " or is copied as an
array of  byte type, " rule to  make assumptions about the effective
types of the target array? I know compilers do this work memcpy...  
Maybe also if a loop is transformed to memcpy?

Martin


Add the following definition after 3.5, paragraph 2:

byte array
object having either no declared type or an array of objects declared with a byte type

byte type
non-atomic character type

Modify 6.5,paragraph 6:
The effective type of an object that is not a byte array, for an access to its
stored value, is the declared type of the object.97) If a value is
stored into a byte array through an lvalue having a byte type, then
the type of the lvalue becomes the effective type of the object for that
access and for subsequent accesses that do not modify the stored value.
If a value is copied into a byte array using memcpy or memmove, or is 
copied as an array of byte type, then the effective type of the
modified object for that access and for subsequent accesses that do not
modify the value is the effective type of the object from which the
value is copied, if it has one. For all other accesses to a byte array,
the effective type of the object is simply the type of the lvalue used
for the access.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3230.pdf



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-03-18 17:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-21  9:23 aliasing Jason Moxham
1999-08-21  9:46 ` aliasing Mark Mitchell
1999-08-31 23:20   ` aliasing Mark Mitchell
1999-08-31 23:20 ` aliasing Jason Moxham
2024-03-18  7:03 aliasing Martin Uecker
2024-03-18  8:26 ` aliasing Richard Biener
2024-03-18 10:55   ` aliasing Martin Uecker
2024-03-18 11:56     ` aliasing Martin Uecker
2024-03-18 13:21       ` aliasing Richard Biener
2024-03-18 15:13         ` aliasing Martin Uecker
2024-03-18  9:00 ` aliasing David Brown
2024-03-18 10:09   ` aliasing Jonathan Wakely
2024-03-18 11:41   ` aliasing Martin Uecker
2024-03-18 13:29     ` aliasing David Brown
2024-03-18 13:54       ` aliasing Andreas Schwab
2024-03-18 16:46         ` aliasing David Brown
2024-03-18 16:55           ` aliasing David Brown
2024-03-18 15:00       ` aliasing Martin Uecker
2024-03-18 17:11         ` aliasing David Brown

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).