aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/expr.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve/extract_5.c71
4 files changed, 83 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index eea0298..7854103 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-06-04 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * expr.c (expand_expr_real_1): Force the operand into memory if
+ its TYPE_MODE is BLKmode and if there is no integer mode for
+ the number of bits being extracted.
+
2018-06-04 Jakub Jelinek <jakub@redhat.com>
PR target/85832
diff --git a/gcc/expr.c b/gcc/expr.c
index 1fa3227..f15037a 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -10579,6 +10579,8 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
to a larger size. */
must_force_mem = (offset
|| mode1 == BLKmode
+ || (mode == BLKmode
+ && !int_mode_for_size (bitsize, 1).exists ())
|| maybe_gt (bitpos + bitsize,
GET_MODE_BITSIZE (mode2)));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 043a4f4..459958e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-06-04 Richard Sandiford <richard.sandiford@linaro.org>
+
+ * gcc.target/aarch64/sve/extract_5.c: New test.
+
2018-06-04 Jakub Jelinek <jakub@redhat.com>
PR target/85832
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/extract_5.c b/gcc/testsuite/gcc.target/aarch64/sve/extract_5.c
new file mode 100644
index 0000000..652ba83
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/extract_5.c
@@ -0,0 +1,71 @@
+/* Originally from gcc.dg/vect/vect-alias-check-10.c. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -msve-vector-bits=512" } */
+
+#define N 87
+#define M 6
+
+typedef signed char sc;
+typedef unsigned char uc;
+typedef signed short ss;
+typedef unsigned short us;
+typedef int si;
+typedef unsigned int ui;
+typedef signed long long sll;
+typedef unsigned long long ull;
+
+#define FOR_EACH_TYPE(M) \
+ M (sc) M (uc) \
+ M (ss) M (us) \
+ M (si) M (ui) \
+ M (sll) M (ull) \
+ M (float) M (double)
+
+#define TEST_VALUE(I) ((I) * 5 / 2)
+
+#define ADD_TEST(TYPE) \
+ void __attribute__((noinline, noclone)) \
+ test_##TYPE (TYPE *a, int step) \
+ { \
+ for (int i = 0; i < N; ++i) \
+ { \
+ a[i * step + 0] = a[i * step + 0] + 1; \
+ a[i * step + 1] = a[i * step + 1] + 2; \
+ a[i * step + 2] = a[i * step + 2] + 4; \
+ a[i * step + 3] = a[i * step + 3] + 8; \
+ } \
+ } \
+ void __attribute__((noinline, noclone)) \
+ ref_##TYPE (TYPE *a, int step) \
+ { \
+ for (int i = 0; i < N; ++i) \
+ { \
+ a[i * step + 0] = a[i * step + 0] + 1; \
+ a[i * step + 1] = a[i * step + 1] + 2; \
+ a[i * step + 2] = a[i * step + 2] + 4; \
+ a[i * step + 3] = a[i * step + 3] + 8; \
+ asm volatile (""); \
+ } \
+ }
+
+#define DO_TEST(TYPE) \
+ for (int j = -M; j <= M; ++j) \
+ { \
+ TYPE a[N * M], b[N * M]; \
+ for (int i = 0; i < N * M; ++i) \
+ a[i] = b[i] = TEST_VALUE (i); \
+ int offset = (j < 0 ? N * M - 4 : 0); \
+ test_##TYPE (a + offset, j); \
+ ref_##TYPE (b + offset, j); \
+ if (__builtin_memcmp (a, b, sizeof (a)) != 0) \
+ __builtin_abort (); \
+ }
+
+FOR_EACH_TYPE (ADD_TEST)
+
+int
+main (void)
+{
+ FOR_EACH_TYPE (DO_TEST)
+ return 0;
+}