When EVRP folds a predicate it reports it only with TDF_DETAILS set as:
Predicate evaluates to: 0
VRP on the other hand always reports it to a dump_file as:
Folding predicate c_10 > 6 to 0
This patch changes fold_cond() in the simplifier to use the latter
format, and converts a couple of EVRP tests to expect the new format.
Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
>From a6bbf1cc9f2847115543d720a99152d7dc2c4892 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Tue, 26 Oct 2021 13:19:05 -0400
Subject: [PATCH 2/3] Unify EVRP and VRP folding predicate message.
EVRP issues a message fior folding predicates in a different format than
VRP does, this patch unifies the messaging.
gcc/
* vr-values.c (simplify_using_ranges::fold_cond): Change fold message.
gcc/testsuite/
* gcc.dg/tree-ssa/evrp9.c: Adjust message scanned for.
* gcc.dg/tree-ssa/pr21458-2.c: Ditto.
---
gcc/testsuite/gcc.dg/tree-ssa/evrp9.c | 6 ++++--
gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c | 2 +-
gcc/vr-values.c | 14 ++++++++++----
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp9.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp9.c
index 6e7828e4340..fb7c319fc43 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/evrp9.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp9.c
@@ -24,5 +24,7 @@ foo (unsigned int x, unsigned int y)
bar ();
}
-/* { dg-final { scan-tree-dump-not "== 5" "evrp" } } */
-/* { dg-final { scan-tree-dump-not "== 6" "evrp" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate minv_.* == 5 to 0" 1 "evrp" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate minv_.* == 6 to 0" 1 "evrp" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate maxv_.* == 5 to 0" 1 "evrp" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate maxv_.* == 6 to 0" 1 "evrp" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
index f8d7353fc0e..9610570e272 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21458-2.c
@@ -16,4 +16,4 @@ foo (int a)
}
}
-/* { dg-final { scan-tree-dump-times "Predicate evaluates to: 1" 1 "evrp" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate.* to 1" 1 "evrp" } } */
diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index 00246c9d3af..ea925f7559d 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -3495,12 +3495,18 @@ simplify_using_ranges::fold_cond (gcond *cond)
if (TREE_CODE (gimple_cond_lhs (cond)) != SSA_NAME
&& TREE_CODE (gimple_cond_rhs (cond)) != SSA_NAME)
return false;
+ if (dump_file)
+ {
+ fprintf (dump_file, "Folding predicate ");
+ print_gimple_expr (dump_file, cond, 0);
+ fprintf (dump_file, " to ");
+ }
edge e0 = EDGE_SUCC (gimple_bb (cond), 0);
edge e1 = EDGE_SUCC (gimple_bb (cond), 1);
if (r.zero_p ())
{
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "\nPredicate evaluates to: 0\n");
+ if (dump_file)
+ fprintf (dump_file, "0\n");
gimple_cond_make_false (cond);
if (e0->flags & EDGE_TRUE_VALUE)
set_and_propagate_unexecutable (e0);
@@ -3509,8 +3515,8 @@ simplify_using_ranges::fold_cond (gcond *cond)
}
else
{
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "\nPredicate evaluates to: 1\n");
+ if (dump_file)
+ fprintf (dump_file, "1\n");
gimple_cond_make_true (cond);
if (e0->flags & EDGE_FALSE_VALUE)
set_and_propagate_unexecutable (e0);
--
2.17.2