aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-07-19 14:02:57 -0400
committerAndrew MacLeod <amacleod@redhat.com>2021-07-22 08:51:59 -0400
commite58093276a6e319c2a6d9f02e343fbf8400dab60 (patch)
tree0eea3cdb0858c34d8b035492f47977a5563f74fd /gcc
parenta6291d88d5b6c17d41950e21d7d452f7f0f73020 (diff)
downloadgcc-e58093276a6e319c2a6d9f02e343fbf8400dab60.zip
gcc-e58093276a6e319c2a6d9f02e343fbf8400dab60.tar.gz
gcc-e58093276a6e319c2a6d9f02e343fbf8400dab60.tar.bz2
Only call vrp_visit_cond_stmt if range_of_stmt doesn't resolve to a const.
Eevntually all functionality will be subsumed. Until then, call it only if needed. gcc/ PR tree-optimization/101496 * vr-values.c (simplify_using_ranges::fold_cond): Call range_of_stmt first, then vrp_visit_cond_Stmt. gcc/testsuite * gcc.dg/pr101496.c: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/pr101496.c22
-rw-r--r--gcc/vr-values.c30
2 files changed, 39 insertions, 13 deletions
diff --git a/gcc/testsuite/gcc.dg/pr101496.c b/gcc/testsuite/gcc.dg/pr101496.c
new file mode 100644
index 0000000..091d4ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101496.c
@@ -0,0 +1,22 @@
+/* PR tree-optimization/101496 */
+/* { dg-do compile } */
+/* { dg-options "-O2 " } */
+
+int c_1, li_2, us_3, func_14_s_5;
+
+void func_14() {
+ {
+ unsigned uli_8 = 0;
+ lbl1806324B:
+ if (uli_8 /= us_3 |= func_14_s_5 < 0 | func_14_s_5 != c_1) {
+ uli_8 += c_1 >= us_3;
+ if (uli_8)
+ ;
+ else
+ li_2 &&func_14_s_5 <= c_1 ?: 0;
+ unsigned *ptr_9 = &uli_8;
+ }
+ }
+ goto lbl1806324B;
+}
+
diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index 1b3ec38..c999ca8 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -3460,11 +3460,6 @@ range_fits_type_p (const value_range *vr,
bool
simplify_using_ranges::fold_cond (gcond *cond)
{
- /* ?? vrp_folder::fold_predicate_in() is a superset of this. At
- some point we should merge all variants of this code. */
- edge taken_edge;
- vrp_visit_cond_stmt (cond, &taken_edge);
-
int_range_max r;
if (query->range_of_stmt (r, cond) && r.singleton_p ())
{
@@ -3475,17 +3470,13 @@ simplify_using_ranges::fold_cond (gcond *cond)
if (r.zero_p ())
{
- gcc_checking_assert (!taken_edge
- || taken_edge->flags & EDGE_FALSE_VALUE);
- if (dump_file && (dump_flags & TDF_DETAILS) && !taken_edge)
+ if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\nPredicate evaluates to: 0\n");
gimple_cond_make_false (cond);
}
else
{
- gcc_checking_assert (!taken_edge
- || taken_edge->flags & EDGE_TRUE_VALUE);
- if (dump_file && (dump_flags & TDF_DETAILS) && !taken_edge)
+ if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\nPredicate evaluates to: 1\n");
gimple_cond_make_true (cond);
}
@@ -3493,12 +3484,25 @@ simplify_using_ranges::fold_cond (gcond *cond)
return true;
}
+ /* ?? vrp_folder::fold_predicate_in() is a superset of this. At
+ some point we should merge all variants of this code. */
+ edge taken_edge;
+ vrp_visit_cond_stmt (cond, &taken_edge);
+
if (taken_edge)
{
if (taken_edge->flags & EDGE_TRUE_VALUE)
- gimple_cond_make_true (cond);
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "\nVRP Predicate evaluates to: 1\n");
+ gimple_cond_make_true (cond);
+ }
else if (taken_edge->flags & EDGE_FALSE_VALUE)
- gimple_cond_make_false (cond);
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "\nVRP Predicate evaluates to: 0\n");
+ gimple_cond_make_false (cond);
+ }
else
gcc_unreachable ();
update_stmt (cond);