]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
noncontiguous ifcombine: skip marking of non-SSA_NAMEs [PR117915]
authorAlexandre Oliva <oliva@adacore.com>
Thu, 19 Dec 2024 01:17:13 +0000 (22:17 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 19 Dec 2024 01:19:35 +0000 (22:19 -0300)
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.

gcc/testsuite/gcc.dg/pr117915.c [new file with mode: 0644]
gcc/tree-ssa-ifcombine.cc

diff --git a/gcc/testsuite/gcc.dg/pr117915.c b/gcc/testsuite/gcc.dg/pr117915.c
new file mode 100644 (file)
index 0000000..5f9f4ec
--- /dev/null
@@ -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;
+}
index de8db2be5572a461d80c8078248d5218451032f6..02c2f5a29b5614231c2710b1dbf4314785677bc7 100644 (file)
@@ -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;
 }