From dba9a0fe801a1460c2959bdceeffde4612df0035 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 27 Oct 2017 14:25:34 +0200 Subject: [PATCH] re PR target/82703 (Wrong addition of std::array components with -O2 -ftree-loop-vectorize -ftree-slp-vectorize (works fine with -O2)) PR target/82703 * config/i386/i386-protos.h (maybe_get_pool_constant): Removed. * config/i386/i386.c (maybe_get_pool_constant): Removed. (ix86_split_to_parts): Use avoid_constant_pool_reference instead of maybe_get_pool_constant. * config/i386/predicates.md (zero_extended_scalar_load_operand): Likewise. * gcc.dg/pr82703.c: New test. From-SVN: r254146 --- gcc/ChangeLog | 12 +++++++++++- gcc/config/i386/i386-protos.h | 2 -- gcc/config/i386/i386.c | 20 +------------------- gcc/config/i386/predicates.md | 4 ++-- gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/gcc.dg/pr82703.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr82703.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 146a82128ad..eb8a9cefa83 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ +2017-10-27 Jakub Jelinek + + PR target/82703 + * config/i386/i386-protos.h (maybe_get_pool_constant): Removed. + * config/i386/i386.c (maybe_get_pool_constant): Removed. + (ix86_split_to_parts): Use avoid_constant_pool_reference instead of + maybe_get_pool_constant. + * config/i386/predicates.md (zero_extended_scalar_load_operand): + Likewise. + 2017-10-24 Qing Zhao - Wilco Dijkstra + Wilco Dijkstra * builtins.c (expand_builtin_update_setjmp_buf): Add a converstion to Pmode from the buf_addr. diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 8bdd67eb608..d2cccf14735 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -282,8 +282,6 @@ extern bool i386_pe_type_dllexport_p (tree); extern int i386_pe_reloc_rw_mask (void); -extern rtx maybe_get_pool_constant (rtx); - extern char internal_label_prefix[16]; extern int internal_label_prefix_len; diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 703687a9e40..82302054101 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -19830,20 +19830,6 @@ ix86_expand_clear (rtx dest) emit_insn (tmp); } -/* X is an unchanging MEM. If it is a constant pool reference, return - the constant pool rtx, else NULL. */ - -rtx -maybe_get_pool_constant (rtx x) -{ - x = ix86_delegitimize_address (XEXP (x, 0)); - - if (GET_CODE (x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (x)) - return get_pool_constant (x); - - return NULL_RTX; -} - void ix86_expand_move (machine_mode mode, rtx operands[]) { @@ -25371,11 +25357,7 @@ ix86_split_to_parts (rtx operand, rtx *parts, machine_mode mode) /* Optimize constant pool reference to immediates. This is used by fp moves, that force all constants to memory to allow combining. */ if (MEM_P (operand) && MEM_READONLY_P (operand)) - { - rtx tmp = maybe_get_pool_constant (operand); - if (tmp) - operand = tmp; - } + operand = avoid_constant_pool_reference (operand); if (MEM_P (operand) && !offsettable_memref_p (operand)) { diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 8f250a2e720..2fc2c60f6ac 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -975,9 +975,9 @@ (match_code "mem") { unsigned n_elts; - op = maybe_get_pool_constant (op); + op = avoid_constant_pool_reference (op); - if (!(op && GET_CODE (op) == CONST_VECTOR)) + if (GET_CODE (op) != CONST_VECTOR) return false; n_elts = CONST_VECTOR_NUNITS (op); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b641f9a7af..97613c0efd8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ +2017-10-27 Jakub Jelinek + + PR target/82703 + * gcc.dg/pr82703.c: New test. + 2017-10-24 Qing Zhao - Wilco Dijkstra + Wilco Dijkstra PR middle-end/80295 * gcc.target/aarch64/pr80295.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr82703.c b/gcc/testsuite/gcc.dg/pr82703.c new file mode 100644 index 00000000000..0bd2f91eea4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr82703.c @@ -0,0 +1,28 @@ +/* PR target/82703 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-tree-sra -ftree-vectorize" } */ + +__attribute__((noinline, noclone)) void +compare (const double *p, const double *q) +{ + for (int i = 0; i < 3; ++i) + if (p[i] != q[i]) + __builtin_abort (); +} + +double vr[3] = { 4, 4, 4 }; + +int +main () +{ + double v1[3] = { 1, 2, 3 }; + double v2[3] = { 3, 2, 1 }; + double v3[3]; + __builtin_memcpy (v3, v1, sizeof (v1)); + for (int i = 0; i < 3; ++i) + v3[i] += v2[i]; + for (int i = 0; i < 3; ++i) + v1[i] += v2[i]; + compare (v3, vr); + return 0; +}