cse.c (try_back_substitute_reg): Move any REG_ARGS_SIZE note when successfully back...
authorJeff Law <law@redhat.com>
Mon, 12 Feb 2018 18:32:18 +0000 (11:32 -0700)
committerJeff Law <law@gcc.gnu.org>
Mon, 12 Feb 2018 18:32:18 +0000 (11:32 -0700)
* cse.c (try_back_substitute_reg): Move any REG_ARGS_SIZE note when
successfully back substituting a reg.

* gcc.c-torture/compile/reg-args-size.c: New test.

From-SVN: r257598

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c [new file with mode: 0644]

index 5a264391268281e1a0cd55ed51207106e0c596df..d5913d0a7db58324d714fc24f7f8e7485283f4f4 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-12  Jeff Law  <law@redhat.com>
+
+       * cse.c (try_back_substitute_reg): Move any REG_ARGS_SIZE note when
+       successfully back substituting a reg.
+
 2018-02-12  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84037
index 825b0bd8989ca4c7a29ba2f02f39f66c953060f3..a73a771041a71460cb1728c2b7037cff606e3d01 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -4256,6 +4256,15 @@ try_back_substitute_reg (rtx set, rtx_insn *insn)
                  && (reg_mentioned_p (dest, XEXP (note, 0))
                      || rtx_equal_p (src, XEXP (note, 0))))
                remove_note (insn, note);
+
+             /* If INSN has a REG_ARGS_SIZE note, move it to PREV.  */
+             note = find_reg_note (insn, REG_ARGS_SIZE, NULL_RTX);
+             if (note != 0)
+               {
+                 remove_note (insn, note);
+                 gcc_assert (!find_reg_note (prev, REG_ARGS_SIZE, NULL_RTX));
+                 set_unique_reg_note (prev, REG_ARGS_SIZE, XEXP (note, 0));
+               }
            }
        }
     }
index dba0bedb7cf2f8536e8429ea7eb7e63b6574329b..8f22a65c7bb7b098b18a58d83fb266f69216fc84 100644 (file)
@@ -1,3 +1,7 @@
+2018-02-12  Jeff Law  <law@redhat.com>
+
+       * gcc.c-torture/compile/reg-args-size.c: New test.
+
 2018-02-12  Carl Love  <cel@us.ibm.com>
 
        * gcc.target/powerpc/builtins-4-runnable.c (main): Move int128 and
diff --git a/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c b/gcc/testsuite/gcc.c-torture/compile/regs-arg-size.c
new file mode 100644 (file)
index 0000000..0ca0b9f
--- /dev/null
@@ -0,0 +1,36 @@
+int foo;
+typedef long unsigned int size_t;
+typedef short unsigned int wchar_t;
+struct tm
+{
+  int tm_mday;
+  int tm_mon;
+  int tm_year;
+};
+size_t
+__strftime (wchar_t * s, size_t maxsize, const wchar_t * format, const struct tm *tim_p)
+{
+  size_t count = 0;
+  int len = 0;
+  size_t i, ctloclen;
+  unsigned long width;
+  {
+    if (foo)
+      {
+       {
+         wchar_t *fmt = L"%s%.*d";
+         len = swprintf (&s[count], maxsize, fmt, "-", width, 0);
+       }
+       if ((count) >= maxsize)
+         return 0;
+      }
+    else
+      {
+       len =
+         swprintf (&s[count], maxsize - count, L"%.2d/%.2d/%.2d", 42, 99, 0);
+       if ((count) >= maxsize)
+         return 0;
+
+      }
+  }
+}