Re: Problem with optimization setting -O3

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

 



On 2010-05-25 23:41, Ian Lance Taylor wrote:
> You need to show us these macros.
> 
> My first guess would be an aliasing violation which is causing trouble
> when combined with the aggressive inlining done at -O3.  In
> particular, see if the code works correctly if you also use the
> -fno-strict-aliasing option.  If it does, you most likely have an
> aliasing violation.
Thanks, Ian.

We are using -fno-strict-aliasing already to make sure the code works
properly (after all GCC warns a lot without its use and our code needs
to make use of these constructs, i.e. type-punning), but the problem
exists nevertheless.

Here the macros. As I mentioned before, the behavior differs between
little and big Endian platforms. x64 is a little Endian platform, though.

/* Little Endian */
#define LEND32(X) (uint32_t)(X)
#define PUT32(X,Y) (*(uint32_t*)(X)) = LEND32(Y)
#define GET32(X) (*(uint32_t*)(X))

/* Big Endian */
#define SWAP32(X) (uint32_t)(((uint32_t)(X) >> 24) | \
                  ((uint32_t)(X) << 24) | \
                  (((uint32_t)(X) >> 8) & 0xff00) | \
                  (((uint32_t)(X) & 0xff00) << 8))
#define LEND32(X) SWAP32(X)
#define GET32(X) (SWAP32(*(uint32_t*)(X)))
#define PUT32(X,Y) (*(uint32_t*)(X)) = LEND32(Y)

Thanks for looking at it,

// Oliver


[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