OSDN Git Service

PR rtl-optimization/53160
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 May 2012 07:19:41 +0000 (07:19 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 2 May 2012 07:19:41 +0000 (07:19 +0000)
* ree.c (combine_reaching_defs): Handle the case where cand->insn
has been modified by ree pass already.

* gcc.c-torture/execute/pr53160.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187036 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ree.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr53160.c [new file with mode: 0644]

index 0d3e198..2f5f0a7 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/53160
+       * ree.c (combine_reaching_defs): Handle the case where cand->insn
+       has been modified by ree pass already.
+
 2012-05-01  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
index 86fd900..25ee7e2 100644 (file)
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -667,6 +667,24 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
   if (!outcome)
     return false;
 
+  /* If cand->insn has been already modified, update cand->mode to a wider
+     mode if possible, or punt.  */
+  if (state->modified[INSN_UID (cand->insn)].kind != EXT_MODIFIED_NONE)
+    {
+      enum machine_mode mode;
+      rtx set;
+
+      if (state->modified[INSN_UID (cand->insn)].kind
+         != (cand->code == ZERO_EXTEND
+             ? EXT_MODIFIED_ZEXT : EXT_MODIFIED_SEXT)
+         || state->modified[INSN_UID (cand->insn)].mode != cand->mode
+         || (set = single_set (cand->insn)) == NULL_RTX)
+       return false;
+      mode = GET_MODE (SET_DEST (set));
+      gcc_assert (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (cand->mode));
+      cand->mode = mode;
+    }
+
   merge_successful = true;
 
   /* Go through the defs vector and try to merge all the definitions
index c04cfb4..aeb17f7 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/53160
+       * gcc.c-torture/execute/pr53160.c: New test.
+
 2012-04-30  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/53148
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr53160.c b/gcc/testsuite/gcc.c-torture/execute/pr53160.c
new file mode 100644 (file)
index 0000000..1187e08
--- /dev/null
@@ -0,0 +1,35 @@
+/* PR rtl-optimization/53160 */
+
+extern void abort (void);
+
+int a, c = 1, d, e, g;
+volatile int b;
+volatile char f;
+long h;
+short i;
+
+void
+foo (void)
+{
+  for (e = 0; e; ++e)
+    ;
+}
+
+int
+main ()
+{
+  if (g)
+    (void) b;
+  foo ();
+  for (d = 0; d >= 0; d--)
+    {
+      short j = f;
+      int k = 0;
+      i = j ? j : j << k;
+    }
+  h = c == 0 ? 0 : i;
+  a = h;
+  if (a != 0)
+    abort ();
+  return 0;
+}