re PR tree-optimization/92645 (Hand written vector code is 450 times slower when...
authorRichard Biener <rguenther@suse.de>
Thu, 28 Nov 2019 12:26:50 +0000 (12:26 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 28 Nov 2019 12:26:50 +0000 (12:26 +0000)
2019-11-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/92645
* tree-inline.c (remap_gimple_stmt): When the return value
is not wanted, elide GIMPLE_RETURN.

* gcc.dg/tree-ssa/inline-12.c: New testcase.

From-SVN: r278807

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/inline-12.c [new file with mode: 0644]
gcc/tree-inline.c

index d4a66fd0e58e5a1d86a6157dc9ed5c9dc4d79f5d..fe76b3e2b4a9c7601f2e80cc04ac8b6ffa01abe0 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92645
+       * tree-inline.c (remap_gimple_stmt): When the return value
+       is not wanted, elide GIMPLE_RETURN.
+
 2019-11-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92645
index a0fdcd5d9de397b7e14709e9892be63302ce4b22..a7533838f989f30da21f581be0cec774c4eba2ac 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92645
+       * gcc.dg/tree-ssa/inline-12.c: New testcase.
+
 2019-11-28  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92645
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/inline-12.c b/gcc/testsuite/gcc.dg/tree-ssa/inline-12.c
new file mode 100644 (file)
index 0000000..250d77e
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-einline" } */
+
+void *foo (void *, int);
+static inline void *mcp (void *src, int i)
+{
+  return foo (src, i);
+}
+void bar()
+{
+  int i;
+  mcp (&i, 0);
+}
+
+/* There should be exactly two assignments, one for both
+   the original foo call and the inlined copy (plus a clobber
+   that doesn't match here).  In particular bar should look like
+     <bb 2> :
+     _4 = foo (&i, 0);
+     i ={v} {CLOBBER};
+     return;  */
+/* { dg-final { scan-tree-dump-times " = " 2 "einline" } } */
index eecf5c6cf1cf7f291ba13d9c5bb47c7ac8f66d27..720f50eefecda2b7b1b03e87ee9988209015d83d 100644 (file)
@@ -1541,9 +1541,12 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
         assignment to the equivalent of the original RESULT_DECL.
         If RETVAL is just the result decl, the result decl has
         already been set (e.g. a recent "foo (&result_decl, ...)");
-        just toss the entire GIMPLE_RETURN.  */
+        just toss the entire GIMPLE_RETURN.  Likewise for when the
+        call doesn't want the return value.  */
       if (retval
          && (TREE_CODE (retval) != RESULT_DECL
+             && (!id->call_stmt
+                 || gimple_call_lhs (id->call_stmt) != NULL_TREE)
              && (TREE_CODE (retval) != SSA_NAME
                  || ! SSA_NAME_VAR (retval)
                  || TREE_CODE (SSA_NAME_VAR (retval)) != RESULT_DECL)))