[Bug target/40550] Segmentation fault caused by alignment error in sse code

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jun 25 17:10:00 GMT 2009



------- Comment #4 from ubizjak at gmail dot com  2009-06-25 17:09 -------
4.4 fixed movaps isse by calling ix86_expand_vector_move to generate unaligned
move.

The core of the problem is however in the middle end, where we expnd from:

main ()
{
  vector float D.1414;
  vector float D.1413;
  vector float D.1412;
  v2sf d;
  v2sf b;
  v2sf a;
  int D.1407;

<bb 2>:
  a = { 1.0e+0, 0.0 };
  b = { 0.0, 1.0e+0 };
  D.1412 = BIT_FIELD_REF <a, 128, 0>;
  D.1413 = BIT_FIELD_REF <b, 128, 0>;
  D.1414 = D.1412 + D.1413;
  d = {D.1414};
  D.1407 = 0;
  return D.1407;

}

So, when BIT_FIELD_REF is expanded, we end at ix86_expand_vector_move through:

#0  ix86_expand_vector_move (mode=V4SFmode, operands=0x7fffffffd9e0) at
../../gcc-svn/branches/gcc-4_4-branch/gcc/config/i386/i386.c:12370
#1  0x00000000008cbc3f in gen_movv4sf (operand0=0x7ffff2888100,
operand1=0x7ffff2888900) at
../../gcc-svn/branches/gcc-4_4-branch/gcc/config/i386/sse.md:194
#2  0x000000000050dc2f in emit_move_insn_1 (x=0x4c, y=0x7ffff2888900) at
../../gcc-svn/branches/gcc-4_4-branch/gcc/expr.c:3355
#3  0x000000000050df37 in emit_move_insn (x=0x7ffff2888100, y=0x7ffff2888900)
at ../../gcc-svn/branches/gcc-4_4-branch/gcc/expr.c:3443
#4  0x0000000000512f0f in store_expr (exp=0x7ffff297d820,
target=0x7ffff2888100, call_param_p=0, nontemporal=0 '\0') at
../../gcc-svn/branches/gcc-4_4-branch/gcc/expr.c:4779
#5  0x0000000000505fd6 in expand_assignment (to=0x7ffff2a5e8c0,
from=0x7ffff297d820, nontemporal=16 '\20') at
../../gcc-svn/branches/gcc-4_4-branch/gcc/expr.c:4395
#6  0x000000000050785f in expand_expr_real_1 (exp=0x7ffff7b7bb80, target=0x0,
tmode=<value optimized out>, modifier=EXPAND_NORMAL, alt_rtl=0x0) at
../../gcc-svn/branches/gcc-4_4-branch/gcc/expr.c:9234
#7  0x000000000050cd57 in expand_expr_real (exp=0x7ffff7b7bb80, target=<value
optimized out>, tmode=<value optimized out>, modifier=<value optimized out>,
alt_rtl=<value optimized out>) at
../../gcc-svn/branches/gcc-4_4-branch/gcc/expr.c:7125

Unfortunatelly, middle end wants to move:

(mem/c/i:V4SF (plus:SI (reg/f:SI 54 virtual-stack-vars)
        (const_int -24 [0xffffffffffffffe8])) [0+0 S16 A32])

and V4SF is wrong mode for V2SF value that lives in memory. And finally, when
assigning the value to "d", we fell off the stack trying to store V4SF to V2SF
slot.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40550



More information about the Gcc-bugs mailing list