Hi!

If a parameter is unused, eipa_sra replaces the SSA_NAMEs with that
PARM_DECL SSA_NAME_VAR with SSA_NAMEs with a VAR_DECL instead.
IMHO it is fine to do that even when all or some of its SSA_NAMEs
are (ab), but we need to copy that flag over.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-03-09  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/70152
        * tree-sra.c (replace_removed_params_ssa_names): Copy over
        SSA_NAME_OCCURS_IN_ABNORMAL_PHI from old_name to new_name.

        * gcc.dg/pr70152.c: New test.

--- gcc/tree-sra.c.jj   2016-02-26 20:30:21.000000000 +0100
+++ gcc/tree-sra.c      2016-03-09 10:55:23.628924709 +0100
@@ -4758,6 +4758,8 @@ replace_removed_params_ssa_names (tree o
 
   repl = get_replaced_param_substitute (adj);
   new_name = make_ssa_name (repl, stmt);
+  SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name)
+    = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (old_name);
 
   if (dump_file)
     {
--- gcc/testsuite/gcc.dg/pr70152.c.jj   2016-03-09 11:04:33.704398525 +0100
+++ gcc/testsuite/gcc.dg/pr70152.c      2016-03-09 11:04:51.815150732 +0100
@@ -0,0 +1,27 @@
+/* PR tree-optimization/70152 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a;
+int foo (void);
+int setjmp (char *);
+char buf[64];
+
+static int
+bar (int x)
+{
+  x = 0;
+  setjmp (buf);
+  for (;;)
+    {
+    switch (x)
+      case 5:
+       x = foo ();
+    }
+}
+
+void
+baz (void)
+{
+  bar (a);
+}

        Jakub

Reply via email to