]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/98786 - fix issue with phiopt and abnormals
authorRichard Biener <rguenther@suse.de>
Fri, 22 Jan 2021 09:34:42 +0000 (10:34 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 5 May 2021 10:12:34 +0000 (12:12 +0200)
This fixes factor_out_conditional_conversion to avoid creating overlapping
lifetimes for abnormals.

2021-01-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/98786
* tree-ssa-phiopt.c (factor_out_conditional_conversion): Avoid
adding new uses of abnormals.

* gcc.dg/torture/pr98786.c: New testcase.

(cherry picked from commit 329f730fd1daa7cdae4a637244d4e215f9bb9a8c)

gcc/testsuite/gcc.dg/torture/pr98786.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr98786.c b/gcc/testsuite/gcc.dg/torture/pr98786.c
new file mode 100644 (file)
index 0000000..ea36471
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-dce" } */
+
+void
+func_30 (void);
+
+int __attribute__ ((pure, returns_twice))
+func_38 (int g_15, int p_39)
+{
+  return !!g_15 ? p_39 : 0;
+}
+
+void
+func_26 (int func_26___trans_tmp_1)
+{
+  long int l_37 = 0;
+  int __trans_tmp_1;
+
+  func_26___trans_tmp_1 = func_38 (func_26___trans_tmp_1, 1);
+  __trans_tmp_1 = func_38 (func_26___trans_tmp_1, l_37);
+  l_37 = 1;
+  func_30 ();
+}
index c6826cb87a2946553a7450c4d24a5f20dd56afc1..96c43eab937f07f4f413d1116c3e999d90f17be2 100644 (file)
@@ -451,6 +451,9 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi,
       if (!is_gimple_reg_type (TREE_TYPE (new_arg0)))
        return NULL;
     }
+  if (TREE_CODE (new_arg0) == SSA_NAME
+      && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_arg0))
+    return NULL;
 
   if (TREE_CODE (arg1) == SSA_NAME)
     {
@@ -465,6 +468,9 @@ factor_out_conditional_conversion (edge e0, edge e1, gphi *phi,
       new_arg1 = gimple_assign_rhs1 (arg1_def_stmt);
       if (convert_code == VIEW_CONVERT_EXPR)
        new_arg1 = TREE_OPERAND (new_arg1, 0);
+      if (TREE_CODE (new_arg1) == SSA_NAME
+         && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_arg1))
+       return NULL;
     }
   else
     {