On 8/20/19 8:39 AM, Richard Biener wrote:
Anyhow, the original patch is OK if you compare OBJ_TYPE_REF_TOKEN/OBJECT irrespective of virtual_method_call_p and order the types_same_for_odr last since that's most expensive.
Hi. It's done in the attached patch that survives bootstrap and regression tests. Martin
>From 645e2df84ccd1f9a4b41f0a73a5398ff81696cdc Mon Sep 17 00:00:00 2001 From: Martin Liska <mli...@suse.cz> Date: Thu, 15 Aug 2019 10:34:41 +0200 Subject: [PATCH 3/9] operand_equal_p: add support for OBJ_TYPE_REF. gcc/ChangeLog: 2019-07-24 Martin Liska <mli...@suse.cz> * fold-const.c (operand_equal_p): Support OBJ_TYPE_REF. * tree.c (add_expr): Hash parts of OBJ_TYPE_REF. --- gcc/fold-const.c | 18 ++++++++++++++++++ gcc/tree.c | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f57fffb9655..12f5a06a524 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3325,6 +3325,24 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) flags &= ~OEP_ADDRESS_OF; return OP_SAME (1) && OP_SAME (2); + /* Virtual table call. */ + case OBJ_TYPE_REF: + { + if (!operand_equal_p (OBJ_TYPE_REF_EXPR (arg0), + OBJ_TYPE_REF_EXPR (arg1), flags)) + return false; + if (tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg0)) + != tree_to_uhwi (OBJ_TYPE_REF_TOKEN (arg1))) + return false; + if (!operand_equal_p (OBJ_TYPE_REF_OBJECT (arg0), + OBJ_TYPE_REF_OBJECT (arg1), flags)) + return false; + if (!types_same_for_odr (obj_type_ref_class (arg0), + obj_type_ref_class (arg1))) + return false; + return true; + } + default: return false; } diff --git a/gcc/tree.c b/gcc/tree.c index b5e5876bbb3..20eb1682435 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -8028,6 +8028,12 @@ add_expr (const_tree t, inchash::hash &hstate, unsigned int flags) inchash::add_expr (TARGET_EXPR_SLOT (t), hstate, flags); return; + /* Virtual table call. */ + case OBJ_TYPE_REF: + inchash::add_expr (OBJ_TYPE_REF_EXPR (t), hstate, flags); + inchash::add_expr (OBJ_TYPE_REF_TOKEN (t), hstate, flags); + inchash::add_expr (OBJ_TYPE_REF_OBJECT (t), hstate, flags); + return; default: break; } -- 2.23.0