public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2883] fur_list should not use the range vector for non-ssa operands.
@ 2023-07-31 16:06 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2023-07-31 16:06 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b769811e7c1b3dff2fa0ec2c37b52859d7bceed4

commit r14-2883-gb769811e7c1b3dff2fa0ec2c37b52859d7bceed4
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Mon Jul 31 10:08:51 2023 -0400

    fur_list should not use the range vector for non-ssa operands.
    
            gcc/
            PR tree-optimization/110582
            * gimple-range-fold.cc (fur_list::get_operand): Do not use the
            range vector for non-ssa names.
    
            gcc/testsuite/
            * gcc.dg/pr110582.c: New.

Diff:
---
 gcc/gimple-range-fold.cc        |  3 ++-
 gcc/testsuite/gcc.dg/pr110582.c | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index d07246008f0..ab2d996c4eb 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -262,7 +262,8 @@ fur_list::fur_list (unsigned num, vrange **list, range_query *q)
 bool
 fur_list::get_operand (vrange &r, tree expr)
 {
-  if (m_index >= m_limit)
+  // Do not use the vector for non-ssa-names, or if it has been emptied.
+  if (TREE_CODE (expr) != SSA_NAME || m_index >= m_limit)
     return m_query->range_of_expr (r, expr);
   r = *m_list[m_index++];
   gcc_checking_assert (range_compatible_p (TREE_TYPE (expr), r.type ()));
diff --git a/gcc/testsuite/gcc.dg/pr110582.c b/gcc/testsuite/gcc.dg/pr110582.c
new file mode 100644
index 00000000000..ae0650d3ae7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110582.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp2" } */
+
+int a, b;
+int main() {
+  char c = a = 0;
+  for (; c != -3; c++) {
+    int d = 2;
+    d ^= 2 && a;
+    b = a == 0 ? d : d / a;
+    a = b;
+  }
+  for (; (1 + 95 << 24) + b + 1 + 686658714L + b - 2297271457;)
+    ;
+}
+
+/* { dg-final { scan-tree-dump-not "Folding predicate" "vrp2" } } */
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-31 16:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 16:06 [gcc r14-2883] fur_list should not use the range vector for non-ssa operands Andrew Macleod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).