When ifcombine_mark_ssa_name is called directly, rather than by ifcombine_mark_ssa_name_walk, we need to check that name is an SSA_NAME at the caller or in the function itself. For convenience and safety, I'm moving the checks from _walk to the implementation proper.
Regstrapped on x86_64-linux-gnu and on ppc64-linux-gnu, along with 3 other ifcombine patches. Ok to install? for gcc/ChangeLog PR tree-optimization/117915 * tree-ssa-ifcombine.cc (ifcombine_mark_ssa_name): Move preconditions from... (ifcombine_mark_ssa_name_walk): ... here. for gcc/testsuite/ChangeLog PR tree-optimization/117915 * gcc.dg/pr117915.c: New. --- gcc/testsuite/gcc.dg/pr117915.c | 9 +++++++++ gcc/tree-ssa-ifcombine.cc | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr117915.c diff --git a/gcc/testsuite/gcc.dg/pr117915.c b/gcc/testsuite/gcc.dg/pr117915.c new file mode 100644 index 0000000000000..4029a20068e9d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr117915.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-copy-prop -fno-tree-vrp" */ + +unsigned a; +int b, c; +int main() { + a = a & b || (c || b) | a; + return 0; +} diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc index de8db2be5572a..02c2f5a29b561 100644 --- a/gcc/tree-ssa-ifcombine.cc +++ b/gcc/tree-ssa-ifcombine.cc @@ -475,7 +475,7 @@ update_profile_after_ifcombine (basic_block inner_cond_bb, static void ifcombine_mark_ssa_name (bitmap used, tree name, basic_block outer) { - if (SSA_NAME_IS_DEFAULT_DEF (name)) + if (!name || TREE_CODE (name) != SSA_NAME || SSA_NAME_IS_DEFAULT_DEF (name)) return; gimple *def = SSA_NAME_DEF_STMT (name); @@ -502,8 +502,7 @@ ifcombine_mark_ssa_name_walk (tree *t, int *, void *data_) { ifcombine_mark_ssa_name_t *data = (ifcombine_mark_ssa_name_t *)data_; - if (*t && TREE_CODE (*t) == SSA_NAME) - ifcombine_mark_ssa_name (data->used, *t, data->outer); + ifcombine_mark_ssa_name (data->used, *t, data->outer); return NULL; } -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive