re PR tree-optimization/88444 (ICE: tree check: expected ssa_name, have integer_cst...
authorJakub Jelinek <jakub@redhat.com>
Tue, 11 Dec 2018 17:16:48 +0000 (18:16 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 11 Dec 2018 17:16:48 +0000 (18:16 +0100)
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.

From-SVN: r267026

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr88444.c [new file with mode: 0644]
gcc/tree-vrp.c

index cc126c7e3ee83d50874e755563e1baf81bce9fbb..94c7ca75cab5fa06f733fc47abb98681cfc7ad4a 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2018-12-11  Dimitar Dimitrov  <dimitar@dinux.eu>
 
        * cfgexpand.c (asm_clobber_reg_is_valid): Also produce
index 3c15bf7c152185cedc2707a0625f5c7633dc8c7d..e69abe6288b38386c585709ee869e8aa8919c92e 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/88444
+       * gcc.dg/pr88444.c: New test.
+
 2018-12-11  Dimitar Dimitrov  <dimitar@dinux.eu>
 
        * gcc.target/i386/pr52813.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr88444.c b/gcc/testsuite/gcc.dg/pr88444.c
new file mode 100644 (file)
index 0000000..01b0d45
--- /dev/null
@@ -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);
+}
index 15ac65b7dd435a714c6a3b8418a2c5e9749fa52a..864de4195da9e25fbd662b62826ed00a51bf3d83 100644 (file)
@@ -2894,6 +2894,7 @@ register_edge_assert_for_2 (tree name, edge 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, edge 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, edge 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]))))