diff options
author | Richard Biener <rguenther@suse.de> | 2024-01-31 10:42:48 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2024-01-31 13:43:21 +0100 |
commit | cfb3f666562fb4ab896a05c234a697afb63627a4 (patch) | |
tree | 231a594e66e4f28cc1b20b724e9c83bf0a99f989 /gcc/tree-ssa-sccvn.cc | |
parent | ccd8da149f5b77ecbf8586b17c6ba79edf2bc745 (diff) | |
download | gcc-cfb3f666562fb4ab896a05c234a697afb63627a4.zip gcc-cfb3f666562fb4ab896a05c234a697afb63627a4.tar.gz gcc-cfb3f666562fb4ab896a05c234a697afb63627a4.tar.bz2 |
tree-optimization/111444 - avoid insertions when skipping defs
The following avoids inserting expressions for IPA CP discovered
equivalences into the VN hashtables when we are optimistically
skipping may-defs in the attempt to prove it's redundant.
PR tree-optimization/111444
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Do not use
vn_reference_lookup_2 when optimistically skipping may-defs.
* gcc.dg/torture/pr111444.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-sccvn.cc')
-rw-r--r-- | gcc/tree-ssa-sccvn.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index f0fa718..9bed9b3 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -2790,25 +2790,29 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, } else { - tree *saved_last_vuse_ptr = data->last_vuse_ptr; - /* Do not update last_vuse_ptr in vn_reference_lookup_2. */ - data->last_vuse_ptr = NULL; tree saved_vuse = vr->vuse; hashval_t saved_hashcode = vr->hashcode; - void *res = vn_reference_lookup_2 (ref, gimple_vuse (def_stmt), - data); + if (vr->vuse) + vr->hashcode = vr->hashcode - SSA_NAME_VERSION (vr->vuse); + vr->vuse = vuse_ssa_val (gimple_vuse (def_stmt)); + if (vr->vuse) + vr->hashcode = vr->hashcode + SSA_NAME_VERSION (vr->vuse); + vn_reference_t vnresult = NULL; + /* Do not use vn_reference_lookup_2 since that might perform + expression hashtable insertion but this lookup crosses + a possible may-alias making such insertion conditionally + invalid. */ + vn_reference_lookup_1 (vr, &vnresult); /* Need to restore vr->vuse and vr->hashcode. */ vr->vuse = saved_vuse; vr->hashcode = saved_hashcode; - data->last_vuse_ptr = saved_last_vuse_ptr; - if (res && res != (void *)-1) + if (vnresult) { - vn_reference_t vnresult = (vn_reference_t) res; if (TREE_CODE (rhs) == SSA_NAME) rhs = SSA_VAL (rhs); if (vnresult->result && operand_equal_p (vnresult->result, rhs, 0)) - return res; + return vnresult; } } } |