]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Return undefined on edges which are not executed.
authorAndrew MacLeod <amacleod@redhat.com>
Wed, 28 Jul 2021 12:30:02 +0000 (08:30 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 28 Jul 2021 12:32:38 +0000 (08:32 -0400)
When a branch has been folded, mark any range requests on the unexecutable edge as
UNDEFINED.

* gimple-range-gori.cc (gori_compute::outgoing_edge_range_p): Check for
cond_false and cond_true on branches.

gcc/gimple-range-gori.cc

index 17032acf8d7fb6221d917dfa4334af56dfe8d00b..c124b3c1ce495d491df55ca5cbea7aae12953732 100644 (file)
@@ -1104,6 +1104,21 @@ gori_compute::outgoing_edge_range_p (irange &r, edge e, tree name,
 
   fur_stmt src (stmt, &q);
 
+  // If this edge is never taken, return undefined.
+  gcond *gc = dyn_cast<gcond *> (stmt);
+  if (gc)
+    {
+      if (((e->flags & EDGE_TRUE_VALUE) && gimple_cond_false_p (gc))
+         || ((e->flags & EDGE_FALSE_VALUE) && gimple_cond_true_p (gc)))
+       {
+         r.set_undefined ();
+         if (dump_file && (dump_flags & TDF_DETAILS))
+             fprintf (dump_file, "Outgoing edge %d->%d unexecutable.\n",
+                      e->src->index, e->dest->index);
+         return true;
+       }
+    }
+
   // If NAME can be calculated on the edge, use that.
   if (is_export_p (name, e->src))
     {