re PR rtl-optimization/47763 (Useless initialization of register)
authorJie Zhang <jie@codesourcery.com>
Wed, 23 Feb 2011 00:25:34 +0000 (00:25 +0000)
committerJie Zhang <jiez@gcc.gnu.org>
Wed, 23 Feb 2011 00:25:34 +0000 (00:25 +0000)
PR rtl-optimization/47763
* web.c (web_main): Ignore naked clobber when replacing register.

testsuite/
PR rtl-optimization/47763
* gcc.dg/pr47763.c: New test.

From-SVN: r170422

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr47763.c [new file with mode: 0644]
gcc/web.c

index 62c848b589c2299ba08caf7e2181c37555af9489..c003c6f88e66f56d6c1fe408c51c2ec2ef1ef7f2 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-23  Jie Zhang  <jie@codesourcery.com>
+
+       PR rtl-optimization/47763
+       * web.c (web_main): Ignore naked clobber when replacing register.
+
 2011-02-22  Anatoly Sokolov  <aesok@post.ru>
 
        * config/stormy16/stormy16.h (REG_OK_FOR_BASE_P, REG_OK_FOR_INDEX_P):
index 14df266e1c1ba52daa3db9799ff0d6f1f7d01845..aa53085b3a074e867de48351f3cd654fc2cbbeda 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-23  Jie Zhang  <jie@codesourcery.com>
+
+       PR rtl-optimization/47763
+       * gcc.dg/pr47763.c: New test.
+
 2011-02-22  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/45743
diff --git a/gcc/testsuite/gcc.dg/pr47763.c b/gcc/testsuite/gcc.dg/pr47763.c
new file mode 100644 (file)
index 0000000..a5da2de
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -funroll-loops -fdump-rtl-web" } */
+
+foo()
+{
+}
+
+/* { dg-final { scan-rtl-dump-not "Web oldreg" "web" } } */
+/* { dg-final { cleanup-rtl-dump "web" } } */
index 9b849249b0d0634067aaaac687c024f18051e428..e57bb37570f8b5fe1d3349d15abb1ac689dcd0c2 100644 (file)
--- a/gcc/web.c
+++ b/gcc/web.c
@@ -377,7 +377,17 @@ web_main (void)
     FOR_BB_INSNS (bb, insn)
     {
       unsigned int uid = INSN_UID (insn);
-      if (NONDEBUG_INSN_P (insn))
+
+      if (NONDEBUG_INSN_P (insn)
+         /* Ignore naked clobber.  For example, reg 134 in the second insn
+            of the following sequence will not be replaced.
+
+              (insn (clobber (reg:SI 134)))
+
+              (insn (set (reg:SI 0 r0) (reg:SI 134)))
+
+            Thus the later passes can optimize them away.  */
+         && GET_CODE (PATTERN (insn)) != CLOBBER)
        {
          df_ref *use_rec;
          df_ref *def_rec;