]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Do not register edges for statements not understood.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 2 Aug 2022 21:31:37 +0000 (17:31 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 2 Aug 2022 23:23:47 +0000 (19:23 -0400)
Previously, all gimple_cond types were undserstoof, with float values,
this is no longer true.  We should gracefully do nothing if the
gcond type is not supported.

PR tree-optimization/106510
gcc/
* gimple-range-fold.cc (fur_source::register_outgoing_edges):
  Check for unsupported statements early.

gcc/testsuite
* gcc.dg/pr106510.c: New.

gcc/gimple-range-fold.cc
gcc/testsuite/gcc.dg/pr106510.c [new file with mode: 0644]

index 923094abd62931dd390b3165268ca55ce27097e6..689d8279627de2c39bf353e220d4066dfcda2ab2 100644 (file)
@@ -1496,6 +1496,10 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge
   tree name;
   basic_block bb = gimple_bb (s);
 
+  range_op_handler handler (s);
+  if (!handler)
+    return;
+
   if (e0)
     {
       // If this edge is never taken, ignore it.
@@ -1524,8 +1528,6 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge
   tree ssa2 = gimple_range_ssa_p (gimple_range_operand2 (s));
   if (ssa1 && ssa2)
     {
-      range_op_handler handler (s);
-      gcc_checking_assert (handler);
       if (e0)
        {
          relation_kind relation = handler.op1_op2_relation (e0_range);
diff --git a/gcc/testsuite/gcc.dg/pr106510.c b/gcc/testsuite/gcc.dg/pr106510.c
new file mode 100644 (file)
index 0000000..24e9112
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void foo ();
+void ine_ok() {
+  float y, x;
+  if (x < y || x > y || y)
+    foo ();
+}
+