public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
@ 2006-03-06 2:30 ` pinskia at gcc dot gnu dot org
2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-06 2:30 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Priority|P2 |P3
Summary|stack deallocation more |[4.0/4.1/4.2 Regression]
|efficient in 3.4 |stack deallocation can be
| |more efficient
Target Milestone|--- |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
2006-03-06 2:30 ` [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient pinskia at gcc dot gnu dot org
@ 2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
2006-06-04 19:06 ` mmitchel at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-03-11 3:20 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.0.3 |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
2006-03-06 2:30 ` [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient pinskia at gcc dot gnu dot org
2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
@ 2006-06-04 19:06 ` mmitchel at gcc dot gnu dot org
2007-02-03 15:43 ` [Bug middle-end/23848] [4.0/4.1/4.2/4.3 " gdr at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 19:06 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2/4.3 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2006-06-04 19:06 ` mmitchel at gcc dot gnu dot org
@ 2007-02-03 15:43 ` gdr at gcc dot gnu dot org
2007-02-03 17:25 ` jsm28 at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-02-03 15:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gdr at gcc dot gnu dot org 2007-02-03 15:42 -------
won't fix in GCC-4.0.4. Adjusting milestone.
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.0.4 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2/4.3 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-02-03 15:43 ` [Bug middle-end/23848] [4.0/4.1/4.2/4.3 " gdr at gcc dot gnu dot org
@ 2007-02-03 17:25 ` jsm28 at gcc dot gnu dot org
2007-02-14 9:13 ` mmitchel at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2007-02-03 17:25 UTC (permalink / raw)
To: gcc-bugs
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2/4.3 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2007-02-03 17:25 ` jsm28 at gcc dot gnu dot org
@ 2007-02-14 9:13 ` mmitchel at gcc dot gnu dot org
2007-11-03 21:19 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-02-14 9:13 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.1.2 |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2/4.3 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2007-02-14 9:13 ` mmitchel at gcc dot gnu dot org
@ 2007-11-03 21:19 ` jakub at gcc dot gnu dot org
2007-11-04 21:36 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-03 21:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jakub at gcc dot gnu dot org 2007-11-03 21:19 -------
Will work on this.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-08-06 15:31:40 |2007-11-03 21:19:40
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2/4.3 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2007-11-03 21:19 ` jakub at gcc dot gnu dot org
@ 2007-11-04 21:36 ` jakub at gcc dot gnu dot org
2007-11-15 19:03 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-04 21:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jakub at gcc dot gnu dot org 2007-11-04 21:35 -------
I'll be testing the following patch. It is quite simplistic, in that it will
give up on bb boundaries, still it should IMHO trigger in quite a lot of cases.
Each optimized out pair of __builtin_stack_save/__builtin_stack_restore will
typically save one call saved register (resp. memory slot if we run out of
them).
--- tree-ssa-ccp.c.jj10 2007-09-04 23:09:30.000000000 +0200
+++ tree-ssa-ccp.c 2007-11-04 22:16:03.000000000 +0100
@@ -2598,6 +2598,76 @@ fold_stmt_inplace (tree stmt)
return changed;
}
+/* Try to optimize out __builtin_stack_restore. Optimize it out
+ if there is another __builtin_stack_restore in the same basic
+ block and no calls or ASM_EXPRs are in between, or if this block's
+ only outgoing edge is to EXIT_BLOCK and there are no calls or
+ ASM_EXPRs after this __builtin_stack_restore. */
+
+static tree
+optimize_stack_restore (basic_block bb, tree call, block_stmt_iterator i)
+{
+ tree stack_save, stmt, callee;
+
+ if (TREE_CODE (call) != CALL_EXPR
+ || call_expr_nargs (call) != 1
+ || TREE_CODE (CALL_EXPR_ARG (call, 0)) != SSA_NAME
+ || !POINTER_TYPE_P (TREE_TYPE (CALL_EXPR_ARG (call, 0))))
+ return NULL_TREE;
+
+ for (bsi_next (&i); !bsi_end_p (i); bsi_next (&i))
+ {
+ tree stmt = bsi_stmt (i);
+ tree call;
+
+ if (TREE_CODE (stmt) == ASM_EXPR)
+ return NULL_TREE;
+ call = get_call_expr_in (stmt);
+ if (call == NULL)
+ continue;
+
+ callee = get_callee_fndecl (call);
+ if (!callee || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL)
+ return NULL_TREE;
+
+ if (DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_RESTORE)
+ break;
+ }
+
+ if (bsi_end_p (i)
+ && (! single_succ_p (bb)
+ || single_succ_edge (bb)->dest != EXIT_BLOCK_PTR))
+ return NULL_TREE;
+
+ stack_save = SSA_NAME_DEF_STMT (CALL_EXPR_ARG (call, 0));
+ if (TREE_CODE (stack_save) != GIMPLE_MODIFY_STMT
+ || GIMPLE_STMT_OPERAND (stack_save, 0) != CALL_EXPR_ARG (call, 0)
+ || TREE_CODE (GIMPLE_STMT_OPERAND (stack_save, 1)) != CALL_EXPR
+ || tree_could_throw_p (stack_save)
+ || !has_single_use (CALL_EXPR_ARG (call, 0)))
+ return NULL_TREE;
+
+ callee = get_callee_fndecl (GIMPLE_STMT_OPERAND (stack_save, 1));
+ if (!callee
+ || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
+ || DECL_FUNCTION_CODE (callee) != BUILT_IN_STACK_SAVE
+ || call_expr_nargs (GIMPLE_STMT_OPERAND (stack_save, 1)) != 0)
+ return NULL_TREE;
+
+ stmt = stack_save;
+ push_stmt_changes (&stmt);
+ if (!set_rhs (&stmt,
+ build_int_cst (TREE_TYPE (CALL_EXPR_ARG (call, 0)), 0)))
+ {
+ discard_stmt_changes (&stmt);
+ return NULL_TREE;
+ }
+ gcc_assert (stmt == stack_save);
+ pop_stmt_changes (&stmt);
+
+ return integer_zero_node;
+}
+
/* Convert EXPR into a GIMPLE value suitable for substitution on the
RHS of an assignment. Insert the necessary statements before
iterator *SI_P.
@@ -2682,6 +2752,12 @@ execute_fold_all_builtins (void)
result = integer_zero_node;
break;
+ case BUILT_IN_STACK_RESTORE:
+ result = optimize_stack_restore (bb, *stmtp, i);
+ if (result)
+ break;
+ /* FALLTHRU */
+
default:
bsi_next (&i);
continue;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2/4.3 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2007-11-04 21:36 ` jakub at gcc dot gnu dot org
@ 2007-11-15 19:03 ` jakub at gcc dot gnu dot org
2007-11-15 19:37 ` [Bug middle-end/23848] [4.0/4.1/4.2 " jakub at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-15 19:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2007-11-15 19:03 -------
Subject: Bug 23848
Author: jakub
Date: Thu Nov 15 19:02:54 2007
New Revision: 130206
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130206
Log:
PR middle-end/23848
* tree-ssa-ccp.c (optimize_stack_restore): New function.
(execute_fold_all_builtins): Call optimize_stack_restore for
BUILT_IN_STACK_RESTORE.
* gcc.dg/tree-ssa/pr23848-1.c: New test.
* gcc.dg/tree-ssa/pr23848-2.c: New test.
* gcc.dg/tree-ssa/pr23848-3.c: New test.
* gcc.dg/tree-ssa/pr23848-4.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr23848-1.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr23848-2.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr23848-3.c
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr23848-4.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-ccp.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2007-11-15 19:03 ` jakub at gcc dot gnu dot org
@ 2007-11-15 19:37 ` jakub at gcc dot gnu dot org
2008-07-04 20:04 ` [Bug middle-end/23848] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 15:47 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-15 19:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jakub at gcc dot gnu dot org 2007-11-15 19:37 -------
Fixed on the trunk.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.0/4.1/4.2/4.3 Regression]|[4.0/4.1/4.2 Regression]
|stack deallocation can be |stack deallocation can be
|more efficient |more efficient
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.2 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2007-11-15 19:37 ` [Bug middle-end/23848] [4.0/4.1/4.2 " jakub at gcc dot gnu dot org
@ 2008-07-04 20:04 ` jsm28 at gcc dot gnu dot org
2009-03-30 15:47 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 12+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 20:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2008-07-04 20:03 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2 Regression] stack |[4.2 Regression] stack
|deallocation can be more |deallocation can be more
|efficient |efficient
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/23848] [4.2 Regression] stack deallocation can be more efficient
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
` (10 preceding siblings ...)
2008-07-04 20:04 ` [Bug middle-end/23848] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 15:47 ` jsm28 at gcc dot gnu dot org
11 siblings, 0 replies; 12+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 15:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jsm28 at gcc dot gnu dot org 2009-03-30 15:46 -------
Closing 4.2 branch, fixed in 4.3.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to fail|4.0.4 |4.0.4 4.2.5
Known to work| |4.3.0
Resolution| |FIXED
Target Milestone|4.2.5 |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23848
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-03-30 15:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-23848-1057@http.gcc.gnu.org/bugzilla/>
2006-03-06 2:30 ` [Bug middle-end/23848] [4.0/4.1/4.2 Regression] stack deallocation can be more efficient pinskia at gcc dot gnu dot org
2006-03-11 3:20 ` mmitchel at gcc dot gnu dot org
2006-06-04 19:06 ` mmitchel at gcc dot gnu dot org
2007-02-03 15:43 ` [Bug middle-end/23848] [4.0/4.1/4.2/4.3 " gdr at gcc dot gnu dot org
2007-02-03 17:25 ` jsm28 at gcc dot gnu dot org
2007-02-14 9:13 ` mmitchel at gcc dot gnu dot org
2007-11-03 21:19 ` jakub at gcc dot gnu dot org
2007-11-04 21:36 ` jakub at gcc dot gnu dot org
2007-11-15 19:03 ` jakub at gcc dot gnu dot org
2007-11-15 19:37 ` [Bug middle-end/23848] [4.0/4.1/4.2 " jakub at gcc dot gnu dot org
2008-07-04 20:04 ` [Bug middle-end/23848] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 15:47 ` jsm28 at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).