From 76ff5c2403e918519f441b073a8b7c1053d62217 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 27 Oct 2017 14:20:55 +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: r254145 --- gcc/ChangeLog | 10 ++++++++++ gcc/config/i386/i386-protos.h | 2 -- gcc/config/i386/i386.c | 20 +------------------- gcc/config/i386/predicates.md | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr82703.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr82703.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fb8ef611502..cdfc0025c63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +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-27 Rainer Orth * doc/install.texi (Specific, i?86-*-solaris2.10): Simplify gas diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index c94cccdfbca..aaed0b747cf 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -277,8 +277,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 1facf121987..6ee6abea258 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -19211,20 +19211,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[]) { @@ -24832,11 +24818,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 c46dd5c83e3..89df15ac55c 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -1004,9 +1004,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 bdbe863dd9c..6cd76b40b96 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-27 Jakub Jelinek + + PR target/82703 + * gcc.dg/pr82703.c: New test. + 2017-10-27 Prathamesh Kulkarni * gcc.dg/ipa/propmalloc-1.c: New test-case. 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; +} -- 2.30.2