vectors and strict aliasing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I understand strict aliasing to be an aspect of standardised C in which distinct types may be assumed by the compiler not to alias one another. GCC appears to regard vectors as distinct from their base scalars, so that mixing vector and scalar accesses to the same data can fall foul of re-ordering.

The documentation for GCC vectors does not specify the layout of data when vectors are stored to memory. If an implementation does not make this guarantee about layout, then I would suggest that there is no portable way to inject/extract individual lanes of a vector (the union technique gets past strict aliasing but it will be  undefined if the representations do not match).

If it is guaranteed to match that of an array (ie the layout inferred by the semantics of pointer arithmetic) then there is no case for the compiler to assume no aliasing. So maybe -fstrict-aliasing should still not assume strict aliasing between vectors and their base scalar types. Or at least there should be a 
-fstrict_aliassing_modulo_vectorisation option.

Note that the lost compiler optimisations may be recovered (where wanted) using the restrict keyword. 

What are the thoughts of the GCC community?

Thanks, John

PS Ian, thank you for your answer to my earlier question: to be certain, one has no choice but to decipher the formal definition





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux