]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow varying ranges of unknown types in irange::verify_range [PR109711]
authorAldy Hernandez <aldyh@redhat.com>
Wed, 3 May 2023 15:29:24 +0000 (17:29 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 3 May 2023 17:15:51 +0000 (19:15 +0200)
The old legacy code allowed building ranges of unknown types so passes
like IPA could build and propagate VARYING.  For now it's easiest to
allow the old behavior, it's not like you can do anything with these
ranges except build them and copy them.

Eventually we should convert all users of set_varying() to use
supported types.  I will address this in my upcoming IPA work.

PR tree-optimization/109711

gcc/ChangeLog:

* value-range.cc (irange::verify_range): Allow types of
error_mark_node.

gcc/testsuite/gcc.dg/tree-ssa/pr109711-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr109711-2.c [new file with mode: 0644]
gcc/value-range.cc

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109711-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109711-1.c
new file mode 100644 (file)
index 0000000..8177750
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+void lspf2lpc();
+
+void interpolate_lpc(int subframe_num) {
+  float weight = 0.25 * subframe_num + 1;
+  if (weight)
+    lspf2lpc();
+}
+
+void qcelp_decode_frame() {
+  int i;
+  for (;; i++)
+    interpolate_lpc(i);
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109711-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109711-2.c
new file mode 100644 (file)
index 0000000..f80bb1a
--- /dev/null
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+void lspf2lpc();
+
+int interpolate_lpc_q_0;
+
+void
+interpolate_lpc(int subframe_num) {
+  float weight;
+  if (interpolate_lpc_q_0)
+    weight = subframe_num;
+  else
+    weight = 1.0;
+  if (weight != 1.0)
+    lspf2lpc();
+}
+
+void
+qcelp_decode_frame() {
+  int i;
+  for (;; i++)
+    interpolate_lpc(i);
+}
index 655ffc2d6d453b6f1b6c5c804274d9b4d108453a..def9299dc0ed780c34c7d011a0b0ece0b2b46517 100644 (file)
@@ -1057,6 +1057,13 @@ irange::verify_range ()
       return;
     }
   gcc_checking_assert (m_num_ranges <= m_max_ranges);
+
+  // Legacy allowed these to represent VARYING for unknown types.
+  // Leave this in for now, until all users are converted.  Eventually
+  // we should abort in set_varying.
+  if (m_kind == VR_VARYING && m_type == error_mark_node)
+    return;
+
   unsigned prec = TYPE_PRECISION (m_type);
   if (m_kind == VR_VARYING)
     {