diff options
author | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-13 14:29:42 +0000 |
---|---|---|
committer | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-13 14:29:42 +0000 |
commit | 55e42d787d77c4142c50790eaf46b4fcecae4f29 (patch) | |
tree | af2735f2d09cbd822cac8b47433a66135561bf9f /gcc/expr.c | |
parent | 1e958bb8ec0b76115358edbebed843022b750ad0 (diff) | |
download | gcc-55e42d787d77c4142c50790eaf46b4fcecae4f29.tar.gz |
2012-03-13 Martin Jambor <mjambor@suse.cz>
* expr.c (expand_assignment): Handle misaligned scalar writes to
memory through top-level MEM_REFs by calling store_bit_field.
* testsuite/gcc.dg/misaligned-expand-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185336 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/gcc/expr.c b/gcc/expr.c index e6fc100f9f8..59b76a4b5f5 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4593,10 +4593,12 @@ expand_assignment (tree to, tree from, bool nontemporal) if ((TREE_CODE (to) == MEM_REF || TREE_CODE (to) == TARGET_MEM_REF) && mode != BLKmode + && !mem_ref_refers_to_non_mem_p (to) && ((align = get_object_or_type_alignment (to)) < GET_MODE_ALIGNMENT (mode)) - && ((icode = optab_handler (movmisalign_optab, mode)) - != CODE_FOR_nothing)) + && (((icode = optab_handler (movmisalign_optab, mode)) + != CODE_FOR_nothing) + || SLOW_UNALIGNED_ACCESS (mode, align))) { addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0)))); @@ -4639,11 +4641,17 @@ expand_assignment (tree to, tree from, bool nontemporal) if (TREE_THIS_VOLATILE (to)) MEM_VOLATILE_P (mem) = 1; - create_fixed_operand (&ops[0], mem); - create_input_operand (&ops[1], reg, mode); - /* The movmisalign<mode> pattern cannot fail, else the assignment would - silently be omitted. */ - expand_insn (icode, 2, ops); + if (icode != CODE_FOR_nothing) + { + create_fixed_operand (&ops[0], mem); + create_input_operand (&ops[1], reg, mode); + /* The movmisalign<mode> pattern cannot fail, else the assignment + would silently be omitted. */ + expand_insn (icode, 2, ops); + } + else + store_bit_field (mem, GET_MODE_BITSIZE (mode), + 0, 0, 0, mode, reg); return; } |