]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jun 2010 13:12:42 +0000 (13:12 +0000)
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jun 2010 13:12:42 +0000 (13:12 +0000)
PR rtl-optimization/44404
* auto-inc-dec.c (find_inc): Use reg_overlap_mentioned_p instead
of count_occurrences to see if it's safe to modify mem_insn.insn.
gcc/testsuite/

gcc/testsuite/
PR rtl-optimization/44404
* gcc.dg/pr44404.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160372 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/auto-inc-dec.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr44404.c [new file with mode: 0644]

index a2abec15d117efbefd7ac93914f6b87004524ada..d0610f5a9df32938f792e83e9788916f4e538ddd 100644 (file)
@@ -1,3 +1,10 @@
+2010-06-07  Kazu Hirata  <kazu@codesourcery.com>
+
+       PR rtl-optimization/44404
+       * auto-inc-dec.c (find_inc): Use reg_overlap_mentioned_p instead
+       of count_occurrences to see if it's safe to modify mem_insn.insn.
+       gcc/testsuite/
+
 2010-06-07  Richard Guenther  <rguenther@suse.de>
 
        * gimplify.c (gimplify_cleanup_point_expr): For empty body
index 6b5c3adecbf947a4a99a2730504f16acffb089f4..94dffc95eb2759ca64a73e3641c0d5693872cadd 100644 (file)
@@ -1068,6 +1068,13 @@ find_inc (bool first_try)
       /* For the post_add to work, the result_reg of the inc must not be
         used in the mem insn since this will become the new index
         register.  */
+      if (count_occurrences (PATTERN (mem_insn.insn), inc_insn.reg_res, 1) == 0
+         && reg_overlap_mentioned_p (inc_insn.reg_res, PATTERN (mem_insn.insn)))
+       {
+         debug_rtx (mem_insn.insn);
+         debug_rtx (inc_insn.reg_res);
+         gcc_unreachable ();
+       }
       if (count_occurrences (PATTERN (mem_insn.insn), inc_insn.reg_res, 1) != 0)
        {
          if (dump_file)
index 7020fc7aa7368d03222abe293589827638a2f874..d93482760521ebd9959c847efab5d11dfbd7a9ef 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-07  Kazu Hirata  <kazu@codesourcery.com>
+
+       PR rtl-optimization/44404
+       * gcc.dg/pr44404.c: New.
+
 2010-06-07  Kai Tietz  <kai.tietz@onevision.com>
 
        PR target/44159
diff --git a/gcc/testsuite/gcc.dg/pr44404.c b/gcc/testsuite/gcc.dg/pr44404.c
new file mode 100644 (file)
index 0000000..a0b4ceb
--- /dev/null
@@ -0,0 +1,35 @@
+/* PR rtl-optimization/44404
+   foo() used to be miscompiled on ARM due to a bug in auto-inc-dec.c,
+   which resulted in "strb r1, [r1], #-36".  */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-unroll-loops" } */
+
+extern char *strcpy (char *, const char *);
+extern int strcmp (const char*, const char*);
+extern void abort (void);
+
+char buf[128];
+
+void __attribute__((noinline))
+bar (int a, const char *p)
+{
+  if (strcmp (p, "0123456789abcdefghijklmnopqrstuvwxyz") != 0)
+    abort ();
+}
+
+void __attribute__((noinline))
+foo (int a)
+{
+  if (a)
+    bar (0, buf);
+  strcpy (buf, "0123456789abcdefghijklmnopqrstuvwxyz");
+  bar (0, buf);
+}
+
+int
+main (void)
+{
+  foo (0);
+  return 0;
+}