http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52450
--- Comment #11 from dave.anglin at bell dot net 2012-03-13 14:41:57 UTC --- On 3/12/2012 5:58 AM, rguenther at suse dot de wrote: > Btw, alignof () of a packed struct type is 1 (it could be nested > in another packed struct). At -O0, the reference passed to foo is misaligned but the struct is copied in foo with memcpy.;; Function foo (foo) foo (struct T t) { v4si D.1253; struct T t.0; # BLOCK 2 # PRED: ENTRY (fallthru) t.0 = t; D.1253_1 = t.0.i[0]; <retval> = D.1253_1; return <retval>; # SUCC: EXIT } ;; t.0 = t; (insn 7 6 8 (set (reg/f:SI 99) (reg/f:SI 91 virtual-stack-vars)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg /torture/pr52402.c:10 -1 (nil)) (insn 8 7 9 (set (reg/f:SI 100) (reg/v/f:SI 98)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402. c:10 -1 (nil)) (insn 9 8 10 (set (reg:SI 101) (const_int 36 [0x24])) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr 52402.c:10 -1 (nil)) (insn 10 9 11 (set (reg:SI 26 %r26) (reg/f:SI 99)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:10 -1 (nil)) (insn 11 10 12 (set (reg:SI 25 %r25) (reg/f:SI 100)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:10 -1 (nil)) (insn 12 11 13 (set (reg:SI 24 %r24) (reg:SI 101)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:10 -1 (nil)) (call_insn 13 12 14 (parallel [ (set (reg:SI 28 %r28) (call (mem:SI (symbol_ref/v:SI ("@memcpy") [flags 0x41] <function_decl 7af9ee00 memcpy>) [0 S4 A32]) (const_int 16 [0x10]))) (clobber (reg:SI 1 %r1)) (clobber (reg:SI 2 %r2)) (use (const_int 0 [0])) ]) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:10 -1 (expr_list:REG_EH_REGION (const_int 0 [0]) (nil)) (expr_list:REG_DEP_TRUE (use (reg:SI 24 %r24)) (expr_list:REG_DEP_TRUE (use (reg:SI 25 %r25)) (expr_list:REG_DEP_TRUE (use (reg:SI 26 %r26)) (nil))))) (insn 14 13 0 (set (reg:SI 102) (reg:SI 28 %r28)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:10 -1 (nil)) At -O1, there is no copy. foo (struct T t) { v4si SR.1; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) SR.1_5 = MEM[(struct T *)&t]; <retval> = SR.1_5; return <retval>; # SUCC: EXIT [100.0%] } ;; <retval> = SR.1_5; (insn 7 6 8 (set (reg:SI 99) (mem/c:SI (reg/v/f:SI 98) [0 MEM[(struct T *)&t]+0 S4 A8])) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:12 -1 (nil)) (insn 8 7 9 (set (mem/c/i:SI (reg/f:SI 97) [0 <retval>+0 S4 A128]) (reg:SI 99)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:12 -1 (nil)) (insn 9 8 10 (set (reg:SI 100) (mem/c:SI (plus:SI (reg/v/f:SI 98) (const_int 4 [0x4])) [0 MEM[(struct T *)&t]+4 S4 A8])) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:12 -1 (nil)) (insn 10 9 11 (set (mem/c/i:SI (plus:SI (reg/f:SI 97) (const_int 4 [0x4])) [0 <retval>+4 S4 A32]) (reg:SI 100)) /test/gnu/gcc/gcc/gcc/testsuite/gcc.dg/torture/pr52402.c:12 -1 (nil)) The alignment of the mem's in insns 7 and 9 is inconsistent with the alignment for the mode. Dave