+2008-03-31 Andrew Pinski <andrew_pinski@playstation.sony.com>
+
+ PR middle-end/30186
+ * fold-const.c (fold_indirect_ref_1): Support accessing non first
+ element of the vector via a pointer.
+
2008-03-31 Ian Lance Taylor <iant@google.com>
* tlink.c (scan_linker_output): Look for symbol name in single
}
}
+ /* ((foo*)&vectorfoo)[1] => BIT_FIELD_REF<vectorfoo,...> */
+ if (TREE_CODE (sub) == POINTER_PLUS_EXPR
+ && TREE_CODE (TREE_OPERAND (sub, 1)) == INTEGER_CST)
+ {
+ tree op00 = TREE_OPERAND (sub, 0);
+ tree op01 = TREE_OPERAND (sub, 1);
+ tree op00type;
+
+ STRIP_NOPS (op00);
+ op00type = TREE_TYPE (op00);
+ if (TREE_CODE (op00) == ADDR_EXPR
+ && TREE_CODE (TREE_TYPE (op00type)) == VECTOR_TYPE
+ && type == TREE_TYPE (TREE_TYPE (op00type)))
+ {
+ HOST_WIDE_INT offset = tree_low_cst (op01, 0);
+ tree part_width = TYPE_SIZE (type);
+ unsigned HOST_WIDE_INT part_widthi = tree_low_cst (part_width, 0)/BITS_PER_UNIT;
+ unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT;
+ tree index = bitsize_int (indexi);
+
+ if (offset/part_widthi <= TYPE_VECTOR_SUBPARTS (TREE_TYPE (op00type)))
+ return fold_build3 (BIT_FIELD_REF, type, TREE_OPERAND (op00, 0),
+ part_width, index);
+
+ }
+ }
+
+
/* ((foo*)&complexfoo)[1] => __imag__ complexfoo */
if (TREE_CODE (sub) == POINTER_PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (sub, 1)) == INTEGER_CST)
+2008-03-31 Andrew Pinski <andrew_pinski@playstation.sony.com>
+
+ PR middle-end/30186
+ * gcc.dg/tree-ssa/vector-1.c: New testcase.
+ * gcc.c-torture/execute/vector-1.c: New testcase.
+ * gcc.c-torture/execute/vector-2.c: New testcase.
+
2008-03-31 Olivier Hainque <hainque@adacore.com>
* gnat.dg/assign_from_packed_pixels.ads: Support for ...
--- /dev/null
+/* Check that vector extraction works correctly. */
+
+#define vector __attribute__((vector_size(16) ))
+
+int f0(vector int t)
+{
+ return ((int*)&t)[0];
+}
+int f1(vector int t)
+{
+ return ((int*)&t)[1];
+}
+int f2(vector int t)
+{
+ return ((int*)&t)[2];
+}
+int f3(vector int t)
+{
+ return ((int*)&t)[3];
+}
+int main(void)
+{
+ vector int a = {0, 1, 2, 3};
+ /* Make sure that we have the correct size for the vectors. */
+ if (sizeof(int) != 4)
+ __builtin_exit (0);
+ if (f0(a) != 0)
+ __builtin_abort ();
+ if (f1(a) != 1)
+ __builtin_abort ();
+ if (f2(a) != 2)
+ __builtin_abort ();
+ if (f3(a) != 3)
+ __builtin_abort ();
+ return 0;
+}
--- /dev/null
+/* Check that vector insertion works correctly. */
+
+#define vector __attribute__((vector_size(16) ))
+
+vector int f0(vector int t, int a)
+{
+ ((int*)&t)[0] = a;
+ return t;
+}
+vector int f1(vector int t, int a)
+{
+ ((int*)&t)[1] = a;
+ return t;
+}
+vector int f2(vector int t, int a)
+{
+ ((int*)&t)[2] = a;
+ return t;
+}
+vector int f3(vector int t, int a)
+{
+ ((int*)&t)[3] = a;
+ return t;
+}
+int main(void)
+{
+ vector int a = {0, 0, 0, 0};
+ vector int b = {1, 0, 0, 0};
+ vector int c = {0, 1, 0, 0};
+ vector int d = {0, 0, 1, 0};
+ vector int e = {0, 0, 0, 1};
+ vector int a0;
+ a0 = f0(a, 1);
+ if (memcmp (&a0, &b, sizeof(a0)))
+ __builtin_abort ();
+ a0 = f1(a, 1);
+ if (memcmp (&a0, &c, sizeof(a0)))
+ __builtin_abort ();
+ a0 = f2(a, 1);
+ if (memcmp (&a0, &d, sizeof(a0)))
+ __builtin_abort ();
+ a0 = f3(a, 1);
+ if (memcmp (&a0, &e, sizeof(a0)))
+ __builtin_abort ();
+ return 0;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-w -O1 -fdump-tree-gimple" } */
+
+
+/* We should be able to produce a BIT_FIELD_REF for each of these vector access. */
+#define vector __attribute__((vector_size(16)))
+float f0(vector float t)
+{
+ return ((float*)&t)[0];
+}
+
+float f1(vector float t)
+{
+ return ((float*)&t)[1];
+}
+
+float f2(vector float t)
+{
+ return ((float*)&t)[2];
+}
+
+float f3(vector float t)
+{
+ return ((float*)&t)[3];
+}
+
+
+/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 4 "gimple"} } */
+
+/* { dg-final { cleanup-tree-dump "gimple" } } */
+
+