Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2020-01-09  Richard Biener  <rguent...@suse.de>

        PR middle-end/93054
        * gimplify.c (gimplify_expr): Deal with NOP definitions.

        * gcc.dg/pr93054.c: New testcase.

Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c      (revision 280006)
+++ gcc/gimplify.c      (working copy)
@@ -14622,7 +14622,8 @@ gimplify_expr (tree *expr_p, gimple_seq
        {
          /* Avoid the extra copy if possible.  */
          *expr_p = create_tmp_reg (TREE_TYPE (name));
-         gimple_set_lhs (SSA_NAME_DEF_STMT (name), *expr_p);
+         if (!gimple_nop_p (SSA_NAME_DEF_STMT (name)))
+           gimple_set_lhs (SSA_NAME_DEF_STMT (name), *expr_p);
          release_ssa_name (name);
        }
     }
Index: gcc/testsuite/gcc.dg/pr93054.c
===================================================================
--- gcc/testsuite/gcc.dg/pr93054.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/pr93054.c      (working copy)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+__attribute__ ((returns_twice)) int
+bp (int);
+
+__attribute__ ((noreturn)) int
+cb (void)
+{
+  return bp (cb ()); /* { dg-warning "declared .noreturn." } */
+}

Reply via email to