freetype-devel
[Top][All Lists]
Advanced

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

[Devel] gcc 3.3 and strict aliasing


From: Vincent Caron
Subject: [Devel] gcc 3.3 and strict aliasing
Date: Mon, 16 Jun 2003 16:47:55 +0200 (CEST)
User-agent: SquirrelMail/1.4.0

Hello,

  compiling from a fresh CVS with gcc 3.3 on Linux, I get 'warning: 
dereferencing
type-punned pointer will break strict-aliasing rule' on many places, like every 
line
of freetype/config/ftmodule.h when included from src/base/ftinit.c, and all
FT_FREE() and FT_NEW() calls.

The '-O2' optimisation turns on gcc's -fstrict-aliasing, whose doc is :

"Allows the compiler to assume the strictest aliasing rules applicable to the 
language
being compiled.  For C (and C++), this activates optimizations based on the 
type of
expressions.  In particular, an object of one type is assumed never to reside 
at the
same  address as an object of a different type, unless the types are almost the 
same. 
For example, an "unsigned int" can alias an "int", but not a "void*" or a 
"double".  A
character type may alias any other type."

Obviously adding -fno-strict-aliasing solves the pb at the cost of an 
optimisation
feature. I've run ftbench on arial.ttf with the library compiled w and w/o this 
flag,
and get noticeable differences. I have run the bench twice for each situation 
to check
numbers where reproductible.

With strict aliasing :

Load                           : 28.814 us/op
Load + Get_Glyph               : 32.599 us/op
Load + Get_Glyph + Get_CBox    : 32.997 us/op
Get_Char_Index                 : 0.143 us/op
CMap cache (1st run)           : 1.756 us/op
CMap cache                     : 0.722 us/op
Outline cache (1st run)        : 31.443 us/op
Outline cache                  : 0.223 us/op
Bitmap cache (1st run)         : 42.692 us/op
Bitmap cache                   : 0.207 us/op
SBit cache (1st run)           : 41.974 us/op
SBit cache                     : 0.200 us/op


Without strict aliasing :

Load                           : 59.379 us/op
Load + Get_Glyph               : 64.335 us/op
Load + Get_Glyph + Get_CBox    : 64.930 us/op
Get_Char_Index                 : 0.298 us/op
CMap cache (1st run)           : 2.078 us/op
CMap cache                     : 0.938 us/op
Outline cache (1st run)        : 61.049 us/op
Outline cache                  : 0.296 us/op
Bitmap cache (1st run)         : 79.417 us/op
Bitmap cache                   : 0.271 us/op
SBit cache (1st run)           : 78.318 us/op
SBit cache                     : 0.270 us/op


I'm running Debian unstable on an Ahtlon-XP SMP machine.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]