http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45722
--- Comment #16 from John David Anglin <danglin at gcc dot gnu.org> 2010-10-11
19:09:48 UTC ---
At -O0, the operation is handled as a COMPONENT_REF. At -O1,
we have a MEM_REF. We get to this point in expand_expr_real_1:
if (mode != BLKmode
&& (unsigned) align < GET_MODE_ALIGNMENT (mode)
/* If the target does not have special handling for unaligned
loads of mode then it can use regular moves for them. */
&& ((icode = optab_handler (movmisalign_optab, mode))
!= CODE_FOR_nothing))
{
rtx reg, insn;
/* We've already validated the memory, and we're creating a
new pseudo destination. The predicates really can't fail. */
reg = gen_reg_rtx (mode);
/* Nor can the insn generator. */
insn = GEN_FCN (icode) (reg, temp);
emit_insn (insn);
return reg;
}
return temp;
As far as I know, there isn't a requirement for target backends to handle
unaligned loads and stores when STRICT_ALIGNMENT is defined.
Further, it's not clear that the code understands that we have an unaligned
load at this point:
(gdb) p debug_tree (exp)
<mem_ref 0x402aea00
type <integer_type 0x40216300 unsigned int sizes-gimplified asm_written
public unsigned SI
size <integer_cst 0x402092b8 constant 32>
unit size <integer_cst 0x402090f0 constant 4>
align 32 symtab 1076433952 alias set -1 canonical type 0x40216300
precision 32 min <integer_cst 0x402092d0 0> max <integer_cst 0x402092a0
4294967295>
pointer_to_this <pointer_type 0x40222360>>
arg 0 <addr_expr 0x402ae9e0
type <pointer_type 0x4028f8a0 type <record_type 0x4028f120 B>
unsigned SI size <integer_cst 0x402092b8 32> unit size <integer_cst
0x402090f0 4>
align 32 symtab 0 alias set -1 canonical type 0x4028f8a0>
constant
arg 0 <var_decl 0x4028f420 sB type <record_type 0x4028f120 B>
addressable used public static common BLK file pr45722-2.c line 18
col 10
size <integer_cst 0x402899f0 constant 48>
unit size <integer_cst 0x40289a20 constant 6>
align 8 context <translation_unit_decl 0x4021de70 D.1226>
(mem/s/c:BLK (symbol_ref:SI ("sB") [flags 0x200] <var_decl
0x4028f420 sB>) [0 sB+0 S6 A8]) chain <function_decl 0x40282700 retitB>>>
arg 1 <integer_cst 0x402ad540 type <pointer_type 0x4028f8a0> constant 2>
pr45722-2.c:48:5>
$1 = void
(gdb) p align
$2 = 32
(gdb) p mode
$3 = SImode
align is not less than the mode alignment for SImode, so even if we had
movmisalign patterns, they wouldn't be used in this case.