This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Use target MEM's alias set in store_constructor (PR middle-end/37730)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 30 Oct 2008 01:21:29 +0100
- Subject: [PATCH] Use target MEM's alias set in store_constructor (PR middle-end/37730)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
useless_type_conversion_p allows the outer type to be void * and the inner
type some other pointer (or vector void * and vector some_type *).
If a vector void * var is assigned say vector char * constructor, then
store_constructor->store_constructor_field->store_field->set_mem_alias_set
might ICE, as void *'s alias set might not conflict with char *'s alias set.
This patch fixes it by always using target's MEM_ALIAS_SET if target is a
MEM. Another possibility could be e.g.:
alias = get_aliase_set (elttype);
if (MEM_P (target)
&& !alias_sets_conflict_p (alias, MEM_ALIAS_SET (target)))
{
gcc_assert (TREE_CODE (elttype) == POINTER_TYPE
&& MEM_ALIAS_SET (target) == get_alias_set (ptr_type_node));
alias = MEM_ALIAS_SET (target);
}
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2008-10-29 Jakub Jelinek <jakub@redhat.com>
PR middle-end/37730
* expr.c (store_constructor): Fro vectors, if target is a MEM, use
target's MEM_ALIAS_SET instead of elttype alias set.
* gcc.dg/vect/pr37730.c: New test.
--- gcc/expr.c.jj 2008-10-27 19:32:24.000000000 +0100
+++ gcc/expr.c 2008-10-29 23:16:25.000000000 +0100
@@ -5579,6 +5579,7 @@ store_constructor (tree exp, rtx target,
HOST_WIDE_INT bitpos;
rtvec vector = NULL;
unsigned n_elts;
+ alias_set_type alias;
gcc_assert (eltmode != BLKmode);
@@ -5630,7 +5631,7 @@ store_constructor (tree exp, rtx target,
if (need_to_clear && size > 0 && !vector)
{
if (REG_P (target))
- emit_move_insn (target, CONST0_RTX (GET_MODE (target)));
+ emit_move_insn (target, CONST0_RTX (GET_MODE (target)));
else
clear_storage (target, GEN_INT (size), BLOCK_OP_NORMAL);
cleared = 1;
@@ -5640,6 +5641,11 @@ store_constructor (tree exp, rtx target,
if (!cleared && !vector && REG_P (target))
emit_move_insn (target, CONST0_RTX (GET_MODE (target)));
+ if (MEM_P (target))
+ alias = MEM_ALIAS_SET (target);
+ else
+ alias = get_alias_set (elttype);
+
/* Store each element of the constructor into the corresponding
element of TARGET, determined by counting the elements. */
for (idx = 0, i = 0;
@@ -5675,7 +5681,7 @@ store_constructor (tree exp, rtx target,
bitpos = eltpos * elt_size;
store_constructor_field (target, bitsize, bitpos,
value_mode, value, type,
- cleared, get_alias_set (elttype));
+ cleared, alias);
}
}
--- gcc/testsuite/gcc.dg/vect/pr37730.c.jj 2008-10-29 23:19:06.000000000 +0100
+++ gcc/testsuite/gcc.dg/vect/pr37730.c 2008-10-29 23:19:36.000000000 +0100
@@ -0,0 +1,16 @@
+/* PR middle-end/37730 */
+/* { dg-do compile } */
+
+void
+add_opush (void)
+{
+ unsigned char formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xff };
+ void *dtds[sizeof (formats)];
+ unsigned int i;
+ unsigned char dtd = 0x08;
+ for (i = 0; i < sizeof (formats); i++)
+ dtds[i] = &dtd;
+ sdp_seq_alloc (dtds);
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Jakub