[x264-devel] gcc stack alignment

aaron aaron_ppus at fmad.co.jp
Fri Dec 19 09:03:29 CET 2008


Hi,

Found a kind of interesting but wrt to stack aligned variables. so in

encoder/slicetype.c :  x264_slicetype_mb_cost() line 194 
(x264-snapshot-20081207-2245)

it declares

DECLARE_ALLIGNED_16( uint8_t edge[33]);

with gcc 4.3.1 edge ends up being on an 8B boundary, and thus the SSE2 asm

predict_8x8_ddl_sse2:
    movdqa   xmm3, [r1+16]

will fault, non 128b aligned address.

My understanding was gcc could not gaurentee the alignment of variables
on the stack? it would only gaurentee the alignment of static/globals
variables?

Quick fix  is either

1) move edge[] to be a static var

2) use movdqu & take the perf hit.

Cheers,
Aaron





More information about the x264-devel mailing list