aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2024-07-19 17:39:40 -0400
committerAndrew MacLeod <amacleod@redhat.com>2024-07-19 17:39:40 -0400
commit01c095ab77f8f43bf77e4c0be6c4f4c0d15a4c29 (patch)
tree4592ca55967c8ae428b1ff88934404bca6f8e61a /gcc
parenta95c1911d8e8fd0c76fc67232ebc1176162ec8d7 (diff)
downloadgcc-01c095ab77f8f43bf77e4c0be6c4f4c0d15a4c29.zip
gcc-01c095ab77f8f43bf77e4c0be6c4f4c0d15a4c29.tar.gz
gcc-01c095ab77f8f43bf77e4c0be6c4f4c0d15a4c29.tar.bz2
Check for SSA_NAME not in the IL yet.
Check for an SSA_NAME not in the CFG before trying to create an equivalence record in the defintion block. PR tree-optimization/116003 gcc/ * value-relation.cc (equiv_oracle::register_initial_def): Check if SSA_NAME is in the IL before registering. gcc/testsuite/ * gcc.dg/pr116003.c: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/pr116003.c21
-rw-r--r--gcc/value-relation.cc6
2 files changed, 26 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/pr116003.c b/gcc/testsuite/gcc.dg/pr116003.c
new file mode 100644
index 0000000..6021058
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr116003.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fnon-call-exceptions -fprofile-arcs -finstrument-functions -fno-tree-copy-prop" } */
+
+_BitInt(5) b5;
+
+char c;
+int i;
+_BitInt(129) b129;
+
+void
+foo(_BitInt(128) b128)
+{
+l50:
+ b128 %= b128 - b129;
+l64:
+ b128 %= c;
+ if (__builtin_add_overflow(i, 0, &c))
+ goto l50;
+ if (__builtin_sub_overflow(c, 0, &b5))
+ goto l64;
+}
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 9293d9e..45722fc 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -607,7 +607,11 @@ equiv_oracle::register_initial_def (tree ssa)
if (SSA_NAME_IS_DEFAULT_DEF (ssa))
return;
basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (ssa));
- gcc_checking_assert (bb && !find_equiv_dom (ssa, bb));
+
+ // If defining stmt is not in the IL, simply return.
+ if (!bb)
+ return;
+ gcc_checking_assert (!find_equiv_dom (ssa, bb));
unsigned v = SSA_NAME_VERSION (ssa);
bitmap_set_bit (m_equiv_set, v);