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.
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.
--- /dev/null
+/* { 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;
+}
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);
{
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;
}