From: Richard Biener Date: Thu, 17 Aug 2023 11:10:14 +0000 (+0200) Subject: tree-optimization/111039 - abnormals and bit test merging X-Git-Tag: releases/gcc-12.4.0~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47e6bff94d980e2fcb6bcb42df04d3b73bd67da7;p=thirdparty%2Fgcc.git tree-optimization/111039 - abnormals and bit test merging The following guards the bit test merging code in if-combine against the appearance of SSA names used in abnormal PHIs. PR tree-optimization/111039 * tree-ssa-ifcombine.cc (ifcombine_ifandif): Check for SSA_NAME_OCCURS_IN_ABNORMAL_PHI. * gcc.dg/pr111039.c: New testcase. (cherry picked from commit 482551a79a3d3f107f6239679ee74655cfe8707e) --- diff --git a/gcc/testsuite/gcc.dg/pr111039.c b/gcc/testsuite/gcc.dg/pr111039.c new file mode 100644 index 000000000000..bec9983b35f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111039.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +int _setjmp (); +void abcd (); +void abcde (); +void compiler_corruption_function(int flags) +{ + int nowait = flags & 1048576, isexpand = flags & 8388608; + abcd(); + _setjmp(flags); + if (nowait && isexpand) + flags &= 0; + abcde(); +} diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc index ce9bbebf9480..b139328af224 100644 --- a/gcc/tree-ssa-ifcombine.cc +++ b/gcc/tree-ssa-ifcombine.cc @@ -415,6 +415,9 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, { tree t, t2; + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1)) + return false; + /* Do it. */ gsi = gsi_for_stmt (inner_cond); t = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1), @@ -465,6 +468,10 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, gimple_stmt_iterator gsi; tree t; + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1) + || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name2)) + return false; + /* Find the common name which is bit-tested. */ if (name1 == name2) ;