]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/111039 - abnormals and bit test merging
authorRichard Biener <rguenther@suse.de>
Thu, 17 Aug 2023 11:10:14 +0000 (13:10 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 17 Aug 2023 13:27:30 +0000 (15:27 +0200)
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.

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

diff --git a/gcc/testsuite/gcc.dg/pr111039.c b/gcc/testsuite/gcc.dg/pr111039.c
new file mode 100644 (file)
index 0000000..bec9983
--- /dev/null
@@ -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();
+}
index 58e19c1508e4e38bbbfb89d1dec21a5dce410127..d5701e8c407b7741313181fc1db8fa9985b50ef4 100644 (file)
@@ -430,6 +430,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),
@@ -486,6 +489,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)
        ;