From 1f060238d5d14f02a9cf29643d8f0bacc3b0a476 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 21 Sep 2018 07:28:42 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 7 + gcc/gimple-ssa-store-merging.c | 17 +- gcc/testsuite/ChangeLog | 4 + .../gcc.c-torture/execute/20180921-1.c | 161 ++++++++++++++++++ 4 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20180921-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8be6771ce50..d71a70b3398 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-09-21 Eric Botcazou + + 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 * 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 c8031e18570..85dd5bccead 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 3b731944529..c68e2c61871 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-09-21 Eric Botcazou + + * gcc.c-torture/execute/20180921-1.c: New test. + 2018-09-20 Marek Polacek 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 00000000000..50d4faa1ac3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20180921-1.c @@ -0,0 +1,161 @@ +/* PR tree-optimization/86990 */ +/* Testcase by Zhendong Su */ + +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; +} -- 2.30.2