aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-09-21 07:28:42 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-09-21 07:28:42 +0000
commit1f060238d5d14f02a9cf29643d8f0bacc3b0a476 (patch)
tree89bccf1aa984378287812717b6320925e633e4b1 /gcc
parent74f310185901571eeec5bc9e7042b993e4c5536f (diff)
downloadgcc-1f060238d5d14f02a9cf29643d8f0bacc3b0a476.zip
gcc-1f060238d5d14f02a9cf29643d8f0bacc3b0a476.tar.gz
gcc-1f060238d5d14f02a9cf29643d8f0bacc3b0a476.tar.bz2
re PR tree-optimization/86990 (wrong code at -O2 on x86_64-linux-gnu in 64-bit mode)
PR tree-optimization/86990 * gimple-ssa-store-merging.c (imm_store_chain_info:coalesce_immediate): Check that the entire merged store group is made of constants only for overlapping stores. From-SVN: r264458
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-ssa-store-merging.c17
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20180921-1.c161
4 files changed, 185 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8be6771..d71a70b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR tree-optimization/86990
+ * gimple-ssa-store-merging.c (imm_store_chain_info:coalesce_immediate):
+ Check that the entire merged store group is made of constants only for
+ overlapping stores.
+
2018-09-20 Allan Sandfeld Jensen <allan.jensen@qt.io>
* gcc.c (LINK_COMMAND_SPEC): Handle -r like -nostdlib.
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index c8031e1..85dd5bc 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -2701,16 +2701,25 @@ imm_store_chain_info::coalesce_immediate_stores ()
merged_store->start + merged_store->width - 1))
{
/* Only allow overlapping stores of constants. */
- if (info->rhs_code == INTEGER_CST
- && merged_store->stores[0]->rhs_code == INTEGER_CST)
+ if (info->rhs_code == INTEGER_CST)
{
+ bool only_constants = true;
+ store_immediate_info *infoj;
+ unsigned int j;
+ FOR_EACH_VEC_ELT (merged_store->stores, j, infoj)
+ if (infoj->rhs_code != INTEGER_CST)
+ {
+ only_constants = false;
+ break;
+ }
unsigned int last_order
= MAX (merged_store->last_order, info->order);
unsigned HOST_WIDE_INT end
= MAX (merged_store->start + merged_store->width,
info->bitpos + info->bitsize);
- if (check_no_overlap (m_store_info, i, INTEGER_CST,
- last_order, end))
+ if (only_constants
+ && check_no_overlap (m_store_info, i, INTEGER_CST,
+ last_order, end))
{
/* check_no_overlap call above made sure there are no
overlapping stores with non-INTEGER_CST rhs_code
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3b73194..c68e2c6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-09-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc.c-torture/execute/20180921-1.c: New test.
+
2018-09-20 Marek Polacek <polacek@redhat.com>
PR c++/87109 - wrong ctor with maybe-rvalue semantics.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20180921-1.c b/gcc/testsuite/gcc.c-torture/execute/20180921-1.c
new file mode 100644
index 0000000..50d4faa
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20180921-1.c
@@ -0,0 +1,161 @@
+/* PR tree-optimization/86990 */
+/* Testcase by Zhendong Su <su@cs.ucdavis.edu> */
+
+const char *ss;
+
+int __attribute__((noipa)) dummy (const char *s, ...)
+{
+ ss = s;
+}
+
+int i[6];
+static int j, v, e, f, h = 5, k, l, n, o, p, q, r, s, u, w, x, y, z, aa, ab, ac,
+ ad, ae, af, ag = 8, ah, ai, aj, ak, al;
+char c;
+struct a {
+ unsigned b;
+ int c : 9;
+ int d;
+} static g = {9, 5};
+static short m[1], t = 95, am;
+int an, ao, ap;
+void aq(int ar) {
+ j = j & 5 ^ i[j ^ v & 5];
+ j = j & 5 ^ i[(j ^ v) & 5];
+ j = j & 4095 ^ (j ^ v) & 5;
+}
+void as(int ar) {
+ if (n)
+ s = 0;
+}
+static unsigned at() {
+ int au[] = {2080555007, 0};
+ for (; al; al--) {
+ if (r)
+ --x;
+ if (g.d)
+ l++;
+ dummy("", j);
+ if (u)
+ ae = n = au[al];
+ }
+ r = 0;
+ return 0;
+}
+int aw(int ar) {
+ int ax[] = {9, 5, 5, 9, 5}, ay = 3;
+ struct a az = {1, 3};
+av:
+ an = (as((at(), ax)[2]), ax[4]);
+ {
+ int ba[] = {5, 5, 9, 8, 1, 0, 5, 5, 9, 8, 1, 0,
+ 5, 5, 9, 8, 1, 0, 5, 5, 9, 8, 1};
+ int a[] = {8, 2, 8, 2, 8, 2, 8};
+ int b[] = {1027239, 8, 1, 7, 9, 2, 9, 4, 4, 2, 8, 1, 0, 4, 4, 2,
+ 4, 4, 2, 9, 2, 9, 8, 1, 7, 9, 2, 9, 4, 4, 2};
+ if (z) {
+ struct a bc;
+ bb:
+ for (; e; e++)
+ for (; q;)
+ return ax[e];
+ if (bc.c < g.d <= a[7])
+ aa--;
+ }
+ {
+ struct a bd = {5};
+ int d[20] = {1, 9, 7, 7, 8, 4, 4, 4, 4, 8, 1, 9, 7, 7, 8, 4, 4, 4, 4};
+ c = h | r % g.c ^ x;
+ dummy("", g);
+ am -= t | x;
+ if (h)
+ while (1) {
+ if (a[o]) {
+ struct a be;
+ if (ar) {
+ struct a bf = {908, 5, 3};
+ int bg[3], bh = k, bj = ag | ae, bk = aj + 3, bl = u << e;
+ if (f)
+ if (ac)
+ ak = w;
+ ag = -(ag & t);
+ af = ag ^ af;
+ if (8 < af)
+ break;
+ if (bj)
+ goto bi;
+ if (s)
+ dummy("", 6);
+ be.d = k;
+ w = f - bh;
+ dummy("", be);
+ if (w)
+ goto bb;
+ ao = r - aa && g.b;
+ if (y)
+ k++;
+ goto av;
+ bi:
+ if (aa)
+ continue;
+ if (f)
+ if (k)
+ dummy("", g);
+ aj = ac + k ^ g.c;
+ g.c = bk;
+ ah = 0;
+ for (; ah < 3; ah++)
+ if (s)
+ bg[ah] = 8;
+ if (!ay)
+ dummy("", ai);
+ u = bl;
+ g = bf;
+ } else
+ for (;; o += a[ap])
+ ;
+ int bm[] = {0};
+ for (; p; p++)
+ c = ad;
+ ad = l;
+ if (bd.c) {
+ dummy(" ");
+ goto bi;
+ }
+ }
+ int bn[] = {5, 2, 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 5,
+ 2, 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 5, 2,
+ 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 5, 2};
+ struct a a[] = {3440025416, 2, 8, 4, 2, 8, 4, 4, 2, 8, 4};
+ struct a b = {3075920};
+ if (f) {
+ aq(m[am + e]);
+ dummy("", j);
+ dummy("", e);
+ ab--;
+ }
+ if (ax[4]) {
+ if (l)
+ goto av;
+ ++f;
+ } else
+ ay = az.c && a;
+ for (; ac; ac++)
+ m[f] = 0;
+ }
+ h = 9;
+ for (; y; y = 1)
+ if (f)
+ goto av;
+ }
+ }
+ return 0;
+}
+
+int main (void)
+{
+ aw(1);
+ if (g.c!= 5)
+ __builtin_abort ();
+ return 0;
+}