Aliasing issue with TAILQ on ppc64 ?

Steffen Daode Nurpmeso sdaoden at gmail.com
Wed Sep 19 13:07:22 UTC 2012


John-Mark Gurney <jmg at funkthat.com> wrote:

 |Poul-Henning Kamp wrote this message on Tue, Sep 18, 2012 at 12:59 +0000:
 |> It may be a good idea to find some way to make sure the compiler
 |> spots the potential aliasing, but I am not sufficiently up to
 |> date on compiler optimizations to know a safe and reliable way
 |> to do that. (Would explicitly casting throuh a void do it ?)
 [.]
 |I'm waiting for an answer from a friend who knows this much better
 |than myself...
 |
 |The relevant part of the C99 standard is section 6.5, paragraphs 6 & 7...

A good rant is on
  http://blog.qt.digia.com/2011/06/10/type-punning-and-strict-aliasing/.
Down in the comments, as a reply from the original poster of it:

  Pay attention to what I said and quoted: without the
  strict-aliasing guarantee, the compiler cannot replace the 10000
  4-byte sets with one 40000-byte memset.

Isn't that just horrible?
For me, when i want to optimize a loop into a memset, i optimize
a loop into a memset, and have some fun to see how it performs
thereafter.  I'll surely have to rework a *lot* of code.

  It’s quite scary because it says this *will* break stuff.

Unbelievable that they simply threw that onto all that code that
had been written before, instead of applying it to types and
pointers that were explicitly declared to be compatible.
Article is worth reading.

--steffen


More information about the freebsd-arch mailing list