Patchwork Fix PR 57442

login
register
mail settings
Submitter Easwaran Raman
Date May 29, 2013, 1:35 a.m.
Message ID <CAPK5YPZMC_0w8q+Zj5iNQDpPZmV6Tzs6+GKPM5ASjHccd6FWww@mail.gmail.com>
Download mbox | patch
Permalink /patch/247086/
State New
Headers show

Comments

Easwaran Raman - May 29, 2013, 1:35 a.m.
I made a thinko when I asserted gcc_unreachable outside the main loop
of appears_later_in_bb in my previous fix to PR 57337. It is quite
possible for STMT1 to be followed by a one or more statements with the
same UID till the end of the BB without encountering STMT2. Right fix
is to return STMT1 outside the loop. Ok for trunk?

Thanks,
Easwaran

2013-05-28  Easwaran Raman  <eraman@google.com>

        PR tree-optimization/57442
        * tree-ssa-reassoc.c (appears_later_in_bb): Return correct value
        when control exits the main loop.

2013-05-28  Easwaran Raman  <eraman@google.com>

        PR tree-optimization/57442
        * gcc.dg/tree-ssa/reassoc-30.c: New testcase.
Richard Guenther - May 29, 2013, 8:09 a.m.
On Wed, May 29, 2013 at 3:35 AM, Easwaran Raman <eraman@google.com> wrote:
> I made a thinko when I asserted gcc_unreachable outside the main loop
> of appears_later_in_bb in my previous fix to PR 57337. It is quite
> possible for STMT1 to be followed by a one or more statements with the
> same UID till the end of the BB without encountering STMT2. Right fix
> is to return STMT1 outside the loop. Ok for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Easwaran
>
> 2013-05-28  Easwaran Raman  <eraman@google.com>
>
>         PR tree-optimization/57442
>         * tree-ssa-reassoc.c (appears_later_in_bb): Return correct value
>         when control exits the main loop.
>
> 2013-05-28  Easwaran Raman  <eraman@google.com>
>
>         PR tree-optimization/57442
>         * gcc.dg/tree-ssa/reassoc-30.c: New testcase.
>
> Index: gcc/testsuite/gcc.dg/tree-ssa/reassoc-30.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/tree-ssa/reassoc-30.c (revision 0)
> +++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-30.c (revision 0)
> @@ -0,0 +1,13 @@
> +/* PR tree-optimization/57442 */
> +/* { dg-do compile } */
> +/* { dg-options "-O1" } */
> +short a;
> +unsigned b;
> +long c;
> +int d;
> +
> +void f(void)
> +{
> +    b = a ? : (a = b) - c + (d - (b + b));
> +}
> +
> Index: gcc/tree-ssa-reassoc.c
> ===================================================================
> --- gcc/tree-ssa-reassoc.c (revision 199385)
> +++ gcc/tree-ssa-reassoc.c (working copy)
> @@ -2888,7 +2888,7 @@ appears_later_in_bb (gimple stmt1, gimple stmt2)
>        else if (stmt == stmt2)
>          return stmt2;
>      }
> -  gcc_unreachable ();
> +  return stmt1;
>  }
>
>  /* Find the statement after which STMT must be moved so that the

Patch

Index: gcc/testsuite/gcc.dg/tree-ssa/reassoc-30.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/reassoc-30.c (revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-30.c (revision 0)
@@ -0,0 +1,13 @@ 
+/* PR tree-optimization/57442 */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+short a;
+unsigned b;
+long c;
+int d;
+
+void f(void)
+{
+    b = a ? : (a = b) - c + (d - (b + b));
+}
+
Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c (revision 199385)
+++ gcc/tree-ssa-reassoc.c (working copy)
@@ -2888,7 +2888,7 @@  appears_later_in_bb (gimple stmt1, gimple stmt2)
       else if (stmt == stmt2)
         return stmt2;
     }
-  gcc_unreachable ();
+  return stmt1;
 }

 /* Find the statement after which STMT must be moved so that the