Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Aliasing in C99

Reply
Thread Tools

Re: Aliasing in C99

 
 
Xavier Roche
Guest
Posts: n/a
 
      05-31-2012
On 05/31/2012 04:01 PM, David Brown wrote:
> It is also possible to use pointers to unions in casts:


This would break strict aliasing, too. You probably need an intermediate
union for that. Another way would be to only use union everywhere (on
x86-64 ABI, it will be stored in a integer register when passed as
argument to functions, so this won't make too much harm)

The unfortunate thing is that gcc, for example, will correctly handle
the integer part, but tend to copy temporarily to the stack the
register, and copy it back to the floating register. (gcc 4.3, Linux
ABI, x86-64)

Note: you may want to check out this excellent introduction to strict
aliasing here:
http://cellperformance.beyond3d.com/...-aliasing.html
 
Reply With Quote
 
 
 
 
Xavier Roche
Guest
Posts: n/a
 
      05-31-2012
Le 31/05/2012 20:47, David Brown a écrit :
> But I think gcc does it this way because the
> floating point data is in an SSE register of some sort, and can't easily
> be moved into a normal register


Hmm, no, you can do that quite easily (movq %rax,%xmm0 for example).

I'm wondering if this is because gcc has troubles extracting pieces of
data inside a structure put in a register (structures of size <= 8 are
packed entirely in a register if I am correct on this architecture)

So I'll double check the produced code on other archs to be sure if I
were you
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Aliasing in C99 Tim Rentsch C Programming 2 06-01-2012 04:07 PM
Re: Aliasing in C99 Eric Sosman C Programming 3 05-31-2012 09:21 PM
Re: Aliasing in C99 James Kuyper C Programming 0 05-31-2012 02:21 PM
C99, strict aliasing Mike C Programming 5 07-21-2010 06:47 AM
C99 complex numbers and aliasing Glen Low C Programming 5 08-20-2004 10:13 PM



Advertisments