From: Richard Biener Date: Mon, 22 Oct 2018 13:57:47 +0000 (+0000) Subject: 2018-10-22 Richard Biener X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e86087eeb8b9cab8caf7f223b602383a3216c810;p=gcc.git 2018-10-22 Richard Biener * gimple-ssa-evrp-analyze.c (evrp_range_analyzer::record_ranges_from_incoming_edge): Be smarter about what ranges to use. * tree-vrp.c (add_assert_info): Dump here. (register_edge_assert_for_2): Instead of here at multiple but not all places. * gcc.dg/tree-ssa/evrp12.c: New testcase. * gcc.dg/predict-6.c: Adjust. * gcc.dg/tree-ssa/vrp33.c: Disable EVRP. * gcc.dg/tree-ssa/vrp02.c: Likewise. * gcc.dg/tree-ssa/cunroll-9.c: Likewise. From-SVN: r265391 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54f36a1278d..96f187500df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2018-10-22 Richard Biener + + * gimple-ssa-evrp-analyze.c + (evrp_range_analyzer::record_ranges_from_incoming_edge): Be + smarter about what ranges to use. + * tree-vrp.c (add_assert_info): Dump here. + (register_edge_assert_for_2): Instead of here at multiple but + not all places. + + * gcc.dg/tree-ssa/evrp12.c: New testcase. + * gcc.dg/predict-6.c: Adjust. + * gcc.dg/tree-ssa/vrp33.c: Disable EVRP. + * gcc.dg/tree-ssa/vrp02.c: Likewise. + * gcc.dg/tree-ssa/cunroll-9.c: Likewise. + 2018-10-22 Steven Bosscher Richard Biener diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c index 83917f5eb0a..b7b0fd8f17c 100644 --- a/gcc/gimple-ssa-evrp-analyze.c +++ b/gcc/gimple-ssa-evrp-analyze.c @@ -203,6 +203,16 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb) ordering issues that can lead to worse ranges. */ for (unsigned i = 0; i < vrs.length (); ++i) { + /* But make sure we do not weaken ranges like when + getting first [64, +INF] and then ~[0, 0] from + conditions like (s & 0x3cc0) == 0). */ + value_range *old_vr = get_value_range (vrs[i].first); + value_range tem (old_vr->kind (), old_vr->min (), old_vr->max ()); + tem.intersect (vrs[i].second); + if (tem.kind () == old_vr->kind () + && tem.min () == old_vr->min () + && tem.max () == old_vr->max ()) + continue; push_value_range (vrs[i].first, vrs[i].second); if (is_fallthru && all_uses_feed_or_dominated_by_stmt (vrs[i].first, stmt)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b803f72cc9b..629f7772793 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,14 @@ +2018-10-22 Richard Biener + + * gcc.dg/tree-ssa/evrp12.c: New testcase. + * gcc.dg/predict-6.c: Adjust. + * gcc.dg/tree-ssa/vrp33.c: Disable EVRP. + * gcc.dg/tree-ssa/vrp02.c: Likewise. + * gcc.dg/tree-ssa/cunroll-9.c: Likewise. + 2018-10-22 Martin Liska - PR tree-optimization/87686 + PR tree-optimization/87686 * g++.dg/tree-ssa/pr87686.C: New test. 2018-10-22 Jakub Jelinek diff --git a/gcc/testsuite/gcc.dg/predict-6.c b/gcc/testsuite/gcc.dg/predict-6.c index 5d6fbf158f2..08ce5cdb81d 100644 --- a/gcc/testsuite/gcc.dg/predict-6.c +++ b/gcc/testsuite/gcc.dg/predict-6.c @@ -10,9 +10,9 @@ void foo (int base, int bound) int i, ret = 0; for (i = base; i <= bound; i++) { - if (i < base) + if (i <= base) global += bar (i); - if (i < base + 1) + if (i < base + 2) global += bar (i); if (i <= base + 3) global += bar (i); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-9.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-9.c index 0e4407dcbd7..886dc147ad1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-9.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-9.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-cunrolli-details" } */ +/* { dg-options "-O2 -fdump-tree-cunrolli-details -fdisable-tree-evrp" } */ void abort (void); int q (void); int a[10]; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp12.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp12.c new file mode 100644 index 00000000000..b3906c23465 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp12.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +extern void link_error (); + +void +f3 (unsigned int s) +{ + if ((s & 0x3cc0) == 0) + { + if (s >= -15552U) + link_error (); + } + else + { + if (s <= 0x3f) + link_error (); + } +} + +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c index 8d14feadb6a..4be538f5944 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks -fdisable-tree-evrp" } */ struct A { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c index 75fefa49925..f1d3863943e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp33.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-fre" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-fre -fdisable-tree-evrp" } */ /* This is from PR14052. */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 28b4d566a52..e3a64fd7e9e 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2299,6 +2299,9 @@ add_assert_info (vec &asserts, info.val = val; info.expr = expr; asserts.safe_push (info); + dump_printf (MSG_NOTE | MSG_PRIORITY_INTERNALS, + "Adding assert for %T from %T %s %T\n", + name, expr, op_symbol_code (comp_code), val); } /* If NAME doesn't have an ASSERT_EXPR registered for asserting @@ -2698,16 +2701,6 @@ register_edge_assert_for_2 (tree name, edge e, tmp = build1 (NOP_EXPR, TREE_TYPE (name), name3); if (cst2 != NULL_TREE) tmp = build2 (PLUS_EXPR, TREE_TYPE (name), tmp, cst2); - - if (dump_file) - { - fprintf (dump_file, "Adding assert for "); - print_generic_expr (dump_file, name3); - fprintf (dump_file, " from "); - print_generic_expr (dump_file, tmp); - fprintf (dump_file, "\n"); - } - add_assert_info (asserts, name3, tmp, comp_code, val); } @@ -2725,16 +2718,6 @@ register_edge_assert_for_2 (tree name, edge e, tmp = build1 (NOP_EXPR, TREE_TYPE (name), tmp); if (cst2 != NULL_TREE) tmp = build2 (PLUS_EXPR, TREE_TYPE (name), tmp, cst2); - - if (dump_file) - { - fprintf (dump_file, "Adding assert for "); - print_generic_expr (dump_file, name2); - fprintf (dump_file, " from "); - print_generic_expr (dump_file, tmp); - fprintf (dump_file, "\n"); - } - add_assert_info (asserts, name2, tmp, comp_code, val); } } @@ -2857,16 +2840,6 @@ register_edge_assert_for_2 (tree name, edge e, cst = fold_build2 (MINUS_EXPR, TREE_TYPE (name2), cst, build_int_cst (TREE_TYPE (name2), 1)); } - - if (dump_file) - { - fprintf (dump_file, "Adding assert for "); - print_generic_expr (dump_file, name2); - fprintf (dump_file, " from "); - print_generic_expr (dump_file, tmp); - fprintf (dump_file, "\n"); - } - add_assert_info (asserts, name2, tmp, new_comp_code, cst); } } @@ -2931,18 +2904,7 @@ register_edge_assert_for_2 (tree name, edge e, } if (new_val) - { - if (dump_file) - { - fprintf (dump_file, "Adding assert for "); - print_generic_expr (dump_file, name2); - fprintf (dump_file, " from "); - print_generic_expr (dump_file, tmp); - fprintf (dump_file, "\n"); - } - - add_assert_info (asserts, name2, tmp, new_comp_code, new_val); - } + add_assert_info (asserts, name2, tmp, new_comp_code, new_val); } /* Add asserts for NAME cmp CST and NAME being defined as @@ -3170,16 +3132,6 @@ register_edge_assert_for_2 (tree name, edge e, maxv2 = maxv - minv; } new_val = wide_int_to_tree (type, maxv2); - - if (dump_file) - { - fprintf (dump_file, "Adding assert for "); - print_generic_expr (dump_file, names[i]); - fprintf (dump_file, " from "); - print_generic_expr (dump_file, tmp); - fprintf (dump_file, "\n"); - } - add_assert_info (asserts, names[i], tmp, LE_EXPR, new_val); } }