http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49281
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2011-06-04 14:57:08 UTC --- Created attachment 24431 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24431 A testcase I got (gdb) r -d foreman_ref_encoder_main.cfg Starting program: /export/home/hjl/bugs/gcc/pr49281/run/h264ref -d foreman_ref_encoder_main.cfg Setting Default Parameters... Parsing Configfile foreman_ref_encoder_main.cfg..................................................................................................... ------------------------------- JM 9.3 (FRExt) -------------------------------- Input YUV file : foreman_qcif.yuv Output H.264 bitstream : encoded_main.264 YUV Format : YUV 4:2:0 Frames to be encoded I-P/B : 62/61 PicInterlace / MbInterlace : 0/0 Transform8x8Mode : 0 ------------------------------------------------------------------------------- Frame Bit/pic WP QP SnrY SnrU SnrV Time(ms) MET(ms) Frm/Fld I D ------------------------------------------------------------------------------- 0000(NVB) 176 0000(IDR) 21032 0 28 37.449 41.305 43.059 0 0 FRM 99 0002(P) 5184 0 28 36.974 41.078 42.818 0 0 FRM 5 Program received signal SIGSEGV, Segmentation fault. 0x00460e67 in compute_colocated (p=0x6f2fe0, listX=<optimized out>) at bar.c:87 87 p->mv[0][i][j][0]=p->mv[0][((i&2)?(i|1):(i&(~1)))][((j&2)?(j|1):(j&(~1)))][0]; (gdb) good.s and bad.s are compiled with -O -ffast-math -mx32: diff -up bad.s good.s --- bad.s 2011-06-04 07:52:19.696326354 -0700 +++ good.s 2011-06-04 07:52:12.514315372 -0700 @@ -23,7 +23,9 @@ compute_colocated: sall $2, %ecx testb $2, %al je .L5 - leal 4(,%rax,4), %ecx + movl %eax, %ecx + orl $1, %ecx + sall $2, %ecx .L5: movl (%ecx,%edx), %edx addl %r9d, %edx @@ -51,7 +53,9 @@ compute_colocated: cmpl $3, (%r8) jle .L7 leal 0(,%r11,4), %r10d - leal 4(,%r11,4), %eax + movl %r11d, %eax + orl $1, %eax + sall $2, %eax movl %r11d, %r9d andl $-2, %r9d sall $2, %r9d