From: Andreas Krebbel <krebbel@linux.ibm.com>
To: gcc-patches@gcc.gnu.org
Cc: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Subject: [PATCH] PR86844: Fix for store merging
Date: Tue, 07 Aug 2018 11:35:00 -0000 [thread overview]
Message-ID: <20180807113526.15097-1-krebbel@linux.ibm.com> (raw)
From: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Bootstrapped and regtested on s390x and x86_64.
gcc/ChangeLog:
2018-08-07 Andreas Krebbel <krebbel@linux.ibm.com>
PR tree-optimization/86844
* gimple-ssa-store-merging.c (check_no_overlap): Add a check to
reject overlaps if it has seen a non-constant store in between.
gcc/testsuite/ChangeLog:
2018-08-07 Andreas Krebbel <krebbel@linux.ibm.com>
PR tree-optimization/86844
* gcc.dg/pr86844.c: New test.
---
gcc/gimple-ssa-store-merging.c | 8 +++++++-
gcc/testsuite/gcc.dg/pr86844.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr86844.c
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index 0ae4581..2abef2e 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -2401,13 +2401,19 @@ check_no_overlap (vec<store_immediate_info *> m_store_info, unsigned int i,
unsigned HOST_WIDE_INT end)
{
unsigned int len = m_store_info.length ();
+ bool seen_group_end_store_p = false;
+
for (++i; i < len; ++i)
{
store_immediate_info *info = m_store_info[i];
if (info->bitpos >= end)
break;
+ if (info->rhs_code != INTEGER_CST)
+ seen_group_end_store_p = true;
if (info->order < last_order
- && (rhs_code != INTEGER_CST || info->rhs_code != INTEGER_CST))
+ && (rhs_code != INTEGER_CST
+ || info->rhs_code != INTEGER_CST
+ || seen_group_end_store_p))
return false;
}
return true;
diff --git a/gcc/testsuite/gcc.dg/pr86844.c b/gcc/testsuite/gcc.dg/pr86844.c
new file mode 100644
index 0000000..9ef08e9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86844.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-require-effective-target stdint_types } */
+/* { dg-options "-O1 -fstore-merging" } */
+
+#include <stdint.h>
+
+struct foo
+{
+ union
+ {
+ uint32_t u4i;
+
+ struct
+ {
+ uint8_t x;
+ uint8_t y;
+ uint8_t z;
+ uint8_t w;
+ } s;
+ } u;
+ uint8_t v;
+};
+
+void __attribute__((noinline,noclone))
+f (struct foo *a)
+{
+ a->u.u4i = 0;
+ a->u.s.w = 222;
+ a->u.s.y = 129;
+ a->u.s.z = a->v;
+}
+
+int
+main ()
+{
+ struct foo s;
+
+ f (&s);
+
+ if (s.u.s.w != 222)
+ __builtin_abort ();
+}
--
2.9.1
next reply other threads:[~2018-08-07 11:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-07 11:35 Andreas Krebbel [this message]
2018-08-17 13:50 ` Richard Biener
2018-08-18 9:20 ` Eric Botcazou
2018-08-20 14:30 ` Jeff Law
2018-09-10 14:06 ` Andreas Krebbel
2018-09-10 17:53 ` Jakub Jelinek
2018-09-11 14:06 ` Andreas Krebbel
2018-09-12 8:54 ` [PATCH] Fix store merging (PR tree-optimization/86844) Jakub Jelinek
2018-09-12 9:04 ` Richard Biener
2018-09-12 9:11 ` Jakub Jelinek
2018-09-12 11:02 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180807113526.15097-1-krebbel@linux.ibm.com \
--to=krebbel@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=krebbel@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).