Commit f17b0ebc by Kyrylo Tkachov Committed by Kyrylo Tkachov

[ARM] PR 68143 Properly update memory offsets when expanding setmem

	PR target/68143
	* config/arm/arm.c (arm_block_set_unaligned_vect): Keep track of
	offset from dstbase and use it appropriately in
	adjust_automodify_address.
	(arm_block_set_aligned_vect): Likewise.

	* gcc.c-torture/execute/pr68143_1.c: New test.

From-SVN: r230462
parent 8502951b
2015-11-17 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/68143
* config/arm/arm.c (arm_block_set_unaligned_vect): Keep track of
offset from dstbase and use it appropriately in
adjust_automodify_address.
(arm_block_set_aligned_vect): Likewise.
2015-11-17 Eric Botcazou <ebotcazou@adacore.com> 2015-11-17 Eric Botcazou <ebotcazou@adacore.com>
* config/visium/t-visium (MULTILIB_OPTIONS): Add muser-mode. * config/visium/t-visium (MULTILIB_OPTIONS): Add muser-mode.
...@@ -29164,7 +29164,7 @@ arm_block_set_unaligned_vect (rtx dstbase, ...@@ -29164,7 +29164,7 @@ arm_block_set_unaligned_vect (rtx dstbase,
rtx (*gen_func) (rtx, rtx); rtx (*gen_func) (rtx, rtx);
machine_mode mode; machine_mode mode;
unsigned HOST_WIDE_INT v = value; unsigned HOST_WIDE_INT v = value;
unsigned int offset = 0;
gcc_assert ((align & 0x3) != 0); gcc_assert ((align & 0x3) != 0);
nelt_v8 = GET_MODE_NUNITS (V8QImode); nelt_v8 = GET_MODE_NUNITS (V8QImode);
nelt_v16 = GET_MODE_NUNITS (V16QImode); nelt_v16 = GET_MODE_NUNITS (V16QImode);
...@@ -29185,7 +29185,7 @@ arm_block_set_unaligned_vect (rtx dstbase, ...@@ -29185,7 +29185,7 @@ arm_block_set_unaligned_vect (rtx dstbase,
return false; return false;
dst = copy_addr_to_reg (XEXP (dstbase, 0)); dst = copy_addr_to_reg (XEXP (dstbase, 0));
mem = adjust_automodify_address (dstbase, mode, dst, 0); mem = adjust_automodify_address (dstbase, mode, dst, offset);
v = sext_hwi (v, BITS_PER_WORD); v = sext_hwi (v, BITS_PER_WORD);
val_elt = GEN_INT (v); val_elt = GEN_INT (v);
...@@ -29202,7 +29202,11 @@ arm_block_set_unaligned_vect (rtx dstbase, ...@@ -29202,7 +29202,11 @@ arm_block_set_unaligned_vect (rtx dstbase,
{ {
emit_insn ((*gen_func) (mem, reg)); emit_insn ((*gen_func) (mem, reg));
if (i + 2 * nelt_mode <= length) if (i + 2 * nelt_mode <= length)
emit_insn (gen_add2_insn (dst, GEN_INT (nelt_mode))); {
emit_insn (gen_add2_insn (dst, GEN_INT (nelt_mode)));
offset += nelt_mode;
mem = adjust_automodify_address (dstbase, mode, dst, offset);
}
} }
/* If there are not less than nelt_v8 bytes leftover, we must be in /* If there are not less than nelt_v8 bytes leftover, we must be in
...@@ -29213,6 +29217,9 @@ arm_block_set_unaligned_vect (rtx dstbase, ...@@ -29213,6 +29217,9 @@ arm_block_set_unaligned_vect (rtx dstbase,
if (i + nelt_v8 < length) if (i + nelt_v8 < length)
{ {
emit_insn (gen_add2_insn (dst, GEN_INT (length - i))); emit_insn (gen_add2_insn (dst, GEN_INT (length - i)));
offset += length - i;
mem = adjust_automodify_address (dstbase, mode, dst, offset);
/* We are shifting bytes back, set the alignment accordingly. */ /* We are shifting bytes back, set the alignment accordingly. */
if ((length & 1) != 0 && align >= 2) if ((length & 1) != 0 && align >= 2)
set_mem_align (mem, BITS_PER_UNIT); set_mem_align (mem, BITS_PER_UNIT);
...@@ -29223,12 +29230,13 @@ arm_block_set_unaligned_vect (rtx dstbase, ...@@ -29223,12 +29230,13 @@ arm_block_set_unaligned_vect (rtx dstbase,
else if (i < length && i + nelt_v8 >= length) else if (i < length && i + nelt_v8 >= length)
{ {
if (mode == V16QImode) if (mode == V16QImode)
{ reg = gen_lowpart (V8QImode, reg);
reg = gen_lowpart (V8QImode, reg);
mem = adjust_automodify_address (dstbase, V8QImode, dst, 0);
}
emit_insn (gen_add2_insn (dst, GEN_INT ((length - i) emit_insn (gen_add2_insn (dst, GEN_INT ((length - i)
+ (nelt_mode - nelt_v8)))); + (nelt_mode - nelt_v8))));
offset += (length - i) + (nelt_mode - nelt_v8);
mem = adjust_automodify_address (dstbase, V8QImode, dst, offset);
/* We are shifting bytes back, set the alignment accordingly. */ /* We are shifting bytes back, set the alignment accordingly. */
if ((length & 1) != 0 && align >= 2) if ((length & 1) != 0 && align >= 2)
set_mem_align (mem, BITS_PER_UNIT); set_mem_align (mem, BITS_PER_UNIT);
...@@ -29255,6 +29263,7 @@ arm_block_set_aligned_vect (rtx dstbase, ...@@ -29255,6 +29263,7 @@ arm_block_set_aligned_vect (rtx dstbase,
rtx rval[MAX_VECT_LEN]; rtx rval[MAX_VECT_LEN];
machine_mode mode; machine_mode mode;
unsigned HOST_WIDE_INT v = value; unsigned HOST_WIDE_INT v = value;
unsigned int offset = 0;
gcc_assert ((align & 0x3) == 0); gcc_assert ((align & 0x3) == 0);
nelt_v8 = GET_MODE_NUNITS (V8QImode); nelt_v8 = GET_MODE_NUNITS (V8QImode);
...@@ -29286,14 +29295,15 @@ arm_block_set_aligned_vect (rtx dstbase, ...@@ -29286,14 +29295,15 @@ arm_block_set_aligned_vect (rtx dstbase,
/* Handle first 16 bytes specially using vst1:v16qi instruction. */ /* Handle first 16 bytes specially using vst1:v16qi instruction. */
if (mode == V16QImode) if (mode == V16QImode)
{ {
mem = adjust_automodify_address (dstbase, mode, dst, 0); mem = adjust_automodify_address (dstbase, mode, dst, offset);
emit_insn (gen_movmisalignv16qi (mem, reg)); emit_insn (gen_movmisalignv16qi (mem, reg));
i += nelt_mode; i += nelt_mode;
/* Handle (8, 16) bytes leftover using vst1:v16qi again. */ /* Handle (8, 16) bytes leftover using vst1:v16qi again. */
if (i + nelt_v8 < length && i + nelt_v16 > length) if (i + nelt_v8 < length && i + nelt_v16 > length)
{ {
emit_insn (gen_add2_insn (dst, GEN_INT (length - nelt_mode))); emit_insn (gen_add2_insn (dst, GEN_INT (length - nelt_mode)));
mem = adjust_automodify_address (dstbase, mode, dst, 0); offset += length - nelt_mode;
mem = adjust_automodify_address (dstbase, mode, dst, offset);
/* We are shifting bytes back, set the alignment accordingly. */ /* We are shifting bytes back, set the alignment accordingly. */
if ((length & 0x3) == 0) if ((length & 0x3) == 0)
set_mem_align (mem, BITS_PER_UNIT * 4); set_mem_align (mem, BITS_PER_UNIT * 4);
...@@ -29315,7 +29325,7 @@ arm_block_set_aligned_vect (rtx dstbase, ...@@ -29315,7 +29325,7 @@ arm_block_set_aligned_vect (rtx dstbase,
for (; (i + nelt_mode <= length); i += nelt_mode) for (; (i + nelt_mode <= length); i += nelt_mode)
{ {
addr = plus_constant (Pmode, dst, i); addr = plus_constant (Pmode, dst, i);
mem = adjust_automodify_address (dstbase, mode, addr, i); mem = adjust_automodify_address (dstbase, mode, addr, offset + i);
emit_move_insn (mem, reg); emit_move_insn (mem, reg);
} }
...@@ -29324,8 +29334,8 @@ arm_block_set_aligned_vect (rtx dstbase, ...@@ -29324,8 +29334,8 @@ arm_block_set_aligned_vect (rtx dstbase,
if (i + UNITS_PER_WORD == length) if (i + UNITS_PER_WORD == length)
{ {
addr = plus_constant (Pmode, dst, i - UNITS_PER_WORD); addr = plus_constant (Pmode, dst, i - UNITS_PER_WORD);
mem = adjust_automodify_address (dstbase, mode, offset += i - UNITS_PER_WORD;
addr, i - UNITS_PER_WORD); mem = adjust_automodify_address (dstbase, mode, addr, offset);
/* We are shifting 4 bytes back, set the alignment accordingly. */ /* We are shifting 4 bytes back, set the alignment accordingly. */
if (align > UNITS_PER_WORD) if (align > UNITS_PER_WORD)
set_mem_align (mem, BITS_PER_UNIT * UNITS_PER_WORD); set_mem_align (mem, BITS_PER_UNIT * UNITS_PER_WORD);
...@@ -29337,7 +29347,8 @@ arm_block_set_aligned_vect (rtx dstbase, ...@@ -29337,7 +29347,8 @@ arm_block_set_aligned_vect (rtx dstbase,
else if (i < length) else if (i < length)
{ {
emit_insn (gen_add2_insn (dst, GEN_INT (length - nelt_mode))); emit_insn (gen_add2_insn (dst, GEN_INT (length - nelt_mode)));
mem = adjust_automodify_address (dstbase, mode, dst, 0); offset += length - nelt_mode;
mem = adjust_automodify_address (dstbase, mode, dst, offset);
/* We are shifting bytes back, set the alignment accordingly. */ /* We are shifting bytes back, set the alignment accordingly. */
if ((length & 1) == 0) if ((length & 1) == 0)
set_mem_align (mem, BITS_PER_UNIT * 2); set_mem_align (mem, BITS_PER_UNIT * 2);
......
2015-11-17 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/68143
* gcc.c-torture/execute/pr68143_1.c: New test.
2015-11-17 Uros Bizjak <ubizjak@gmail.com> 2015-11-17 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/torture/pr68264.c: Use dg-add-options ieee. * gcc.dg/torture/pr68264.c: Use dg-add-options ieee.
......
#define NULL 0
struct stuff
{
int a;
int b;
int c;
int d;
int e;
char *f;
int g;
};
void __attribute__ ((noinline))
bar (struct stuff *x)
{
if (x->g != 2)
__builtin_abort ();
}
int
main (int argc, char** argv)
{
struct stuff x = {0, 0, 0, 0, 0, NULL, 0};
x.a = 100;
x.d = 100;
x.g = 2;
/* Struct should now look like {100, 0, 0, 100, 0, 0, 0, 2}. */
bar (&x);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment