aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-04-21 15:03:43 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-04-21 16:34:05 -0400
commitf828503eeb79ad1f1ada6db7deccc5abcc2f3ca3 (patch)
tree5bf85bc2b76f66361323926c92125ab2800f7310 /gcc/tree-vrp.cc
parent03cebd304955a6b9c5607e09312d77f1307cc98e (diff)
downloadgcc-f828503eeb79ad1f1ada6db7deccc5abcc2f3ca3.zip
gcc-f828503eeb79ad1f1ada6db7deccc5abcc2f3ca3.tar.gz
gcc-f828503eeb79ad1f1ada6db7deccc5abcc2f3ca3.tar.bz2
Do not fold ADDR_EXPR conditions leading to builtin_unreachable early.
Ranges can not represent &var globally yet, so we cannot fold these expressions early or we lose the __builtin_unreachable information. PR tree-optimization/109546 gcc/ * tree-vrp.cc (remove_unreachable::remove_and_update_globals): Do not fold conditions with ADDR_EXPR early. gcc/testsuite/ * gcc.dg/pr109546.c: New.
Diffstat (limited to 'gcc/tree-vrp.cc')
-rw-r--r--gcc/tree-vrp.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index f4d48452..9b87064 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -150,7 +150,9 @@ remove_unreachable::remove_and_update_globals (bool final_p)
// If this is already a constant condition, don't look either
if (!lhs_p && !rhs_p)
continue;
-
+ // Do not remove addresses early. ie if (x == &y)
+ if (!final_p && lhs_p && TREE_CODE (gimple_cond_rhs (s)) == ADDR_EXPR)
+ continue;
bool dominate_exit_p = true;
FOR_EACH_GORI_EXPORT_NAME (m_ranger.gori (), e->src, name)
{