This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [middle-end] PR c/29092, vector types not compatible when they should be
Bah - you shouldn't introduce more users of TREE_CHAIN. Use a VEC
instead please.
Hmm, right, lazy me. Bubblestrapped and ran the SIMD tests on
powerpc-apple-darwin8.7.0 and i686-pc-linux-gnu; bootstrap and regtest
running on the latter (now at stage2).
Paolo
2006-09-25 Paolo Bonzini <bonzini@gnu.org>
PR c/29092
* tree.c (make_vector_type): Memoize types.
(used_vector_types): New.
2006-09-25 Paolo Bonzini <bonzini@gnu.org>
PR c/29092
* gcc.target/powerpc/20030218-1.c: Fix failing testcase.
* gcc.dg/simd-5.c, gcc.dg/simd-6: New testcases.
Index: tree.c
===================================================================
--- tree.c (revision 116745)
+++ tree.c (working copy)
@@ -165,7 +165,6 @@ static int int_cst_hash_eq (const void *
static void print_type_hash_statistics (void);
static void print_debug_expr_statistics (void);
static void print_value_expr_statistics (void);
-static tree make_vector_type (tree, int, enum machine_mode);
static int type_hash_marked_p (const void *);
static unsigned int type_hash_list (tree, hashval_t);
static unsigned int attribute_hash_list (tree, hashval_t);
@@ -6365,10 +6364,24 @@ omp_clause_operand_check_failed (int idx
and mapped to the machine mode MODE. Initialize its fields and build
the information necessary for debugging output. */
+static VEC(tree, gc) *used_vector_types;
+
static tree
-make_vector_type (tree innertype, int nunits, enum machine_mode mode)
+make_vector_type (tree innertype, unsigned nunits, enum machine_mode mode)
{
- tree t = make_node (VECTOR_TYPE);
+ unsigned ix;
+ tree t;
+
+ if (!used_vector_types)
+ used_vector_types = VEC_alloc (tree, gc, 10);
+
+ for (ix = 0; VEC_iterate(tree, used_vector_types, ix, t); ix++)
+ if (lang_hooks.types_compatible_p (TREE_TYPE (t), innertype)
+ && TYPE_VECTOR_SUBPARTS (t) == nunits
+ && (mode == VOIDmode || mode == TYPE_MODE (t)))
+ return t;
+
+ t = make_node (VECTOR_TYPE);
TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype);
SET_TYPE_VECTOR_SUBPARTS (t, nunits);
@@ -6404,6 +6417,7 @@ make_vector_type (tree innertype, int nu
nunits, mode));
}
+ VEC_safe_push (tree, gc, used_vector_types, t);
return t;
}
@@ -6847,6 +6861,19 @@ build_vector_type (tree innertype, int n
return make_vector_type (innertype, nunits, VOIDmode);
}
+/* Similarly, but takes the inner type and number of units, which must be
+ a power of two. The resulting vector uses a copy of INNERTYPE, which
+ makes the vector type distinct from other types with the same mode. */
+
+tree
+build_opaque_vector_type (tree innertype, int nunits)
+{
+ innertype = copy_node (innertype);
+ TYPE_MAIN_VARIANT (innertype) = innertype;
+
+ return make_vector_type (innertype, nunits, VOIDmode);
+}
+
/* Build RESX_EXPR with given REGION_NUMBER. */
tree
build_resx (int region_number)
Index: testsuite/gcc.target/powerpc/20030218-1.c
===================================================================
--- testsuite/gcc.target/powerpc/20030218-1.c (revision 116745)
+++ testsuite/gcc.target/powerpc/20030218-1.c (working copy)
@@ -18,7 +18,7 @@ main (void)
vfloat = vshort; /* { dg-error "incompatible types in assignment" } */
/* Just because this is a V2SI, it doesn't make it an opaque. */
- vint = vshort; /* { dg-error "incompatible types in assignment" } */
+ vint = vfloat; /* { dg-error "incompatible types in assignment" } */
return 0;
}
/* { dg-do compile } */
/* { dg-options "-O2 -std=gnu89" } */
/* Ensure that we don't need a typedef to initialize a vector type. */
#define vector __attribute__ ((vector_size (8)))
vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" } */
vector char y = (vector short) {1,2,3,4}; /* { dg-error "initializer" } */
/* { dg-do compile } */
/* { dg-options "-O2 -std=gnu99" } */
/* Ensure that we don't need a typedef to initialize a vector type. */
#define vector __attribute__ ((vector_size (8)))
vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" "" { xfail *-*-* } } */
vector char y = (vector short) {1,2,3,4}; /* { dg-error "initializer" } */