aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKazu Hirata <kazu@codesourcery.com>2010-06-07 13:12:42 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2010-06-07 13:12:42 +0000
commit5e52ffc4f0176747fb9290aaa7b9bb7fa9c1b332 (patch)
treee785d101633aa2238c1b438f15db3d87ca4ae178 /gcc
parentae0595b089bfb006687b60a0a8a4e6420909424f (diff)
downloadgcc-5e52ffc4f0176747fb9290aaa7b9bb7fa9c1b332.zip
gcc-5e52ffc4f0176747fb9290aaa7b9bb7fa9c1b332.tar.gz
gcc-5e52ffc4f0176747fb9290aaa7b9bb7fa9c1b332.tar.bz2
re PR rtl-optimization/44404 (auto-inc-dec generates an invalid assembly instruction)
gcc/ 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. From-SVN: r160372
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/auto-inc-dec.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr44404.c35
4 files changed, 54 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a2abec1..d0610f5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c
index 6b5c3ad..94dffc9 100644
--- a/gcc/auto-inc-dec.c
+++ b/gcc/auto-inc-dec.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7020fc7..d934827 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..a0b4ceb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr44404.c
@@ -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;
+}