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]

[PATCH] Add TREE_CODE == SSA_NAME checks to register_edge_assert_for_2 (PR tree-optimization/88444)


Hi!

Most spots in vr-values* and tree-vrp* check if convert rhs1 is SSA_NAME,
but these 3 spots don't.  It can appear if some pass doesn't fold stmts
after changing them.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-12-11  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/88444
	* tree-vrp.c (register_edge_assert_for_2): Only register assertions
	for conversions if rhs1 is a SSA_NAME.

	* gcc.dg/pr88444.c: New test.

--- gcc/tree-vrp.c.jj	2018-12-07 00:27:25.419941079 +0100
+++ gcc/tree-vrp.c	2018-12-11 09:39:27.994469666 +0100
@@ -2894,6 +2894,7 @@ register_edge_assert_for_2 (tree name, e
 	{
 	  name2 = gimple_assign_rhs1 (def_stmt);
 	  if (CONVERT_EXPR_CODE_P (rhs_code)
+	      && TREE_CODE (name2) == SSA_NAME
 	      && INTEGRAL_TYPE_P (TREE_TYPE (name2))
 	      && TYPE_UNSIGNED (TREE_TYPE (name2))
 	      && prec == TYPE_PRECISION (TREE_TYPE (name2))
@@ -2990,6 +2991,7 @@ register_edge_assert_for_2 (tree name, e
 	  wide_int rmin, rmax;
 	  tree rhs1 = gimple_assign_rhs1 (def_stmt);
 	  if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
+	      && TREE_CODE (rhs1) == SSA_NAME
 	      /* Make sure the relation preserves the upper/lower boundary of
 	         the range conservatively.  */
 	      && (comp_code == NE_EXPR
@@ -3054,6 +3056,7 @@ register_edge_assert_for_2 (tree name, e
 		{
 		  names[1] = gimple_assign_rhs1 (def_stmt2);
 		  if (!CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt2))
+		      || TREE_CODE (names[1]) != SSA_NAME
 		      || !INTEGRAL_TYPE_P (TREE_TYPE (names[1]))
 		      || (TYPE_PRECISION (TREE_TYPE (name2))
 			  != TYPE_PRECISION (TREE_TYPE (names[1]))))
--- gcc/testsuite/gcc.dg/pr88444.c.jj	2018-12-11 09:43:50.062166005 +0100
+++ gcc/testsuite/gcc.dg/pr88444.c	2018-12-11 09:43:34.393423360 +0100
@@ -0,0 +1,30 @@
+/* PR tree-optimization/88444 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-vrp -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" } */
+
+int v;
+
+int
+foo (int, int);
+
+static inline int
+bar (long int x)
+{
+  return !!x ? x : 1;
+}
+
+static inline void
+baz (int x)
+{
+  v += foo (0, 0) + bar (x);
+}
+
+void
+qux (void)
+{
+  int a = 0;
+  v = v || foo (0, 0);
+  v = v || foo (0, 0);
+  v = v || foo (0, 0);
+  baz (a);
+}

	Jakub


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