This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix optimize_range_tests_var_bound (PR tree-optimization/77901)


On October 8, 2016 9:09:43 PM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>I forgot to take into account that ranges[i].exp might not be just NULL
>or
>SSA_NAME, but it can be e.g. BIT_AND_EXPR etc. when optimized by
>earlier
>optimize_range_tests* optimizations.  We only care about SSA_NAMEs or
>the
>a < b comparisons that can be ranges[i].exp == NULL if they are in
>GIMPLE_COND.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

>2016-10-08  Jakub Jelinek  <jakub@redhat.com>
>
>	PR tree-optimization/77901
>	* tree-ssa-reassoc.c (optimize_range_tests_var_bound): Only optimize
>	if ranges[i].exp is SSA_NAME when looking for >= and only when
>	ranges[i].exp is NULL or SSA_NAME when looking for the other
>	comparison.
>
>	* gcc.c-torture/compile/pr77901.c: New test.
>
>--- gcc/tree-ssa-reassoc.c.jj	2016-10-07 11:32:51.000000000 +0200
>+++ gcc/tree-ssa-reassoc.c	2016-10-08 18:01:32.773394195 +0200
>@@ -2846,7 +2846,9 @@ optimize_range_tests_var_bound (enum tre
> 
>   for (i = first; i < length; i++)
>     {
>-      if (ranges[i].exp == NULL_TREE || !ranges[i].in_p)
>+      if (ranges[i].exp == NULL_TREE
>+	  || TREE_CODE (ranges[i].exp) != SSA_NAME
>+	  || !ranges[i].in_p)
> 	continue;
> 
>       tree type = TREE_TYPE (ranges[i].exp);
>@@ -2878,6 +2880,8 @@ optimize_range_tests_var_bound (enum tre
>       tree rhs1, rhs2;
>       if (ranges[i].exp)
> 	{
>+	  if (TREE_CODE (ranges[i].exp) != SSA_NAME)
>+	    continue;
> 	  stmt = SSA_NAME_DEF_STMT (ranges[i].exp);
> 	  if (!is_gimple_assign (stmt))
> 	    continue;
>--- gcc/testsuite/gcc.c-torture/compile/pr77901.c.jj	2016-10-08
>18:05:47.590172355 +0200
>+++ gcc/testsuite/gcc.c-torture/compile/pr77901.c	2016-10-08
>18:05:31.000000000 +0200
>@@ -0,0 +1,10 @@
>+/* PR tree-optimization/77901 */
>+
>+void bar (void);
>+
>+void
>+foo (int *x, long *y)
>+{
>+  if (*y && *x != 10 && *x != 12 && *y >= 0)
>+    bar ();
>+}
>
>	Jakub



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]