Hi!

live_bytes is non-NULL always, m_live_bytes is auto_sbitmap that is
constructed in dse_dom_walker ctor:
  dse_dom_walker (cdi_direction direction)
    : dom_walker (direction),
    m_live_bytes (PARAM_VALUE (PARAM_DSE_MAX_OBJECT_SIZE)),
    m_byte_tracking_enabled (false) {}
Whether live_bytes tracks anything right now or not is determined by
byte_tracking_enabled flag.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-10-02  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/82387
        PR tree-optimization/82388
        PR tree-optimization/82389
        * tree-ssa-dse.c (dse_classify_store): Test byte_tracking_enabled
        instead of live_bytes non-NULL.

        * gcc.c-torture/compile/pr82389.c: New test.
        * gcc.c-torture/execute/pr82387.c: New test.
        * gcc.c-torture/execute/pr82388.c: New test.

--- gcc/tree-ssa-dse.c.jj       2017-09-29 23:05:40.000000000 +0200
+++ gcc/tree-ssa-dse.c  2017-10-02 11:04:56.231304016 +0200
@@ -577,10 +577,10 @@ dse_classify_store (ao_ref *ref, gimple
          /* If the statement is a use the store is not dead.  */
          else if (ref_maybe_used_by_stmt_p (use_stmt, ref))
            {
-             /* Handle common cases where we can easily build a ao_ref
+             /* Handle common cases where we can easily build an ao_ref
                 structure for USE_STMT and in doing so we find that the
                 references hit non-live bytes and thus can be ignored.  */
-             if (live_bytes && (!gimple_vdef (use_stmt) || !temp))
+             if (byte_tracking_enabled && (!gimple_vdef (use_stmt) || !temp))
                {
                  if (is_gimple_assign (use_stmt))
                    {
--- gcc/testsuite/gcc.c-torture/compile/pr82389.c.jj    2017-10-02 
12:46:39.921427169 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr82389.c       2017-10-02 
12:44:43.000000000 +0200
@@ -0,0 +1,13 @@
+/* PR tree-optimization/82389 */
+
+void bar (short);
+
+void
+foo (void)
+{
+  short a[5];
+  int b;
+  for (b = -1290603998; b < 5; b++)
+    a[b] = 0;
+  bar (a[3]);
+}
--- gcc/testsuite/gcc.c-torture/execute/pr82387.c.jj    2017-10-02 
12:46:18.474690151 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr82387.c       2017-10-02 
12:46:03.000000000 +0200
@@ -0,0 +1,27 @@
+/* PR tree-optimization/82387 */
+
+struct A { int b; };
+int f = 1;
+
+struct A
+foo (void)
+{
+  struct A h[] = { 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+    {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+  };
+  return h[24];
+}
+
+int
+main ()
+{
+  struct A i = foo (), j = i;
+  j.b && (f = 0);
+  return f; 
+}
--- gcc/testsuite/gcc.c-torture/execute/pr82388.c.jj    2017-10-02 
12:46:22.675638638 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr82388.c       2017-10-02 
12:45:14.000000000 +0200
@@ -0,0 +1,17 @@
+/* PR tree-optimization/82388 */
+
+struct A { int b; int c; int d; } e;
+
+struct A
+foo (void)
+{
+  struct A h[30] = {{0,0,0}};
+  return h[29]; 
+}
+
+int
+main ()
+{
+  e = foo ();
+  return e.b; 
+}

        Jakub

Reply via email to