diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-07-31 10:08:51 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-07-31 12:01:27 -0400 |
commit | b769811e7c1b3dff2fa0ec2c37b52859d7bceed4 (patch) | |
tree | 2258f614cfa60ac6ada690077ba2c0abdf38710c /gcc | |
parent | b67c98a547757b40678c788a53fab38379f58d03 (diff) | |
download | gcc-b769811e7c1b3dff2fa0ec2c37b52859d7bceed4.zip gcc-b769811e7c1b3dff2fa0ec2c37b52859d7bceed4.tar.gz gcc-b769811e7c1b3dff2fa0ec2c37b52859d7bceed4.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-range-fold.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr110582.c | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index d072460..ab2d996 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 0000000..ae0650d --- /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" } } */ + |