[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-23 Thread steven at gcc dot gnu dot org

--- Additional Comments From steven at gcc dot gnu dot org  2005-02-23 
11:23 ---
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01387.html

-- 
   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread jakub at gcc dot gnu dot org

--- Additional Comments From jakub at gcc dot gnu dot org  2005-02-22 14:15 
---
This is a DOM bug.
Comment above lookup_avail_expr says:
   NOTE: This function assumes that STMT is a MODIFY_EXPR node that
   contains no CALL_EXPR on its RHS and makes no volatile nor
   aliased references.  */
and I have no reason not to believe this, if not perhaps for const calls, then
certainly for pure calls.  For pure calls the code would need to invalidate
all recorded pure calls whenever a stmt might modify global state.
But optimize_stmt/eliminate_redundant_computations will happily call
lookup_avail_expr with a CALL_EXPR on the RHS, because const/pure calls don't
have TREE_SIDE_EFFECTS set.

I have tried:
--- tree-ssa-dom.c.jj  2005-02-17 20:02:58.0 +0100
+++ tree-ssa-dom.c  2005-02-22 14:40:14.912216290 +0100
@@ -2964,7 +2964,8 @@ optimize_stmt (struct dom_walk_data *wal
|| (TREE_CODE (stmt) == MODIFY_EXPR
 ! TREE_SIDE_EFFECTS (TREE_OPERAND (stmt, 1)))
|| TREE_CODE (stmt) == COND_EXPR
-   || TREE_CODE (stmt) == SWITCH_EXPR));
+   || TREE_CODE (stmt) == SWITCH_EXPR)
+ get_call_expr_in (stmt) == NULL);

   if (may_optimize_p)
 may_have_exposed_new_symbols

which fixes this, but it seems no other tree-SSA optimization is able to 
optimize
say extern int foo (void) __attribute__((pure)); ... a = foo (); a += foo ();
into a = 2 * foo ();, fortunately RTL optimizations optimize that.

If const calls are actually handled correctly by lookup_avail_expr, then
the comment above it ought to be changed and we could only avoid optimizing
DECL_IS_PURE calls in addition to TREE_SIDE_EFFECTS rhs' in optimize_stmt.

-- 
   What|Removed |Added

 CC||law at redhat dot com,
   ||dnovillo at redhat dot com
   Severity|normal  |critical


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread pinskia at gcc dot gnu dot org

--- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-22 
14:19 ---
Note this was cause by:
2005-01-26  Diego Novillo  [EMAIL PROTECTED]

PR tree-optimization/19633
* tree-ssa-alias.c (ptr_is_dereferenced_by): Also handle
CALL_EXPRs.
(maybe_create_global_var): Do not create .GLOBAL_VAR if there
are no call-clobbered variables.
* tree-outof-ssa.c (check_replaceable): Return false for calls
with side-effects.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread pinskia at gcc dot gnu dot org

--- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-22 
14:21 ---
Also note that DOM is doing the correct thing as the DOM does not know that 
func_other could 
change the value of func_pure.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread pinskia at gcc dot gnu dot org

--- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-22 
14:56 ---
 For pure calls the code would need to invalidate
 all recorded pure calls whenever a stmt might modify global state.
Yes this was done with GLOBAL_VAR before Diego's patch but now it is not done 
with anything else.  
This is basically the same issue as PR 20100.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread dnovillo at gcc dot gnu dot org


-- 
   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |dnovillo at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED
   Last reconfirmed|2005-02-22 07:28:59 |2005-02-22 14:58:42
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread dnovillo at gcc dot gnu dot org

--- Additional Comments From dnovillo at gcc dot gnu dot org  2005-02-22 
18:26 ---

Testing patch.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-22 Thread cvs-commit at gcc dot gnu dot org

--- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-02-23 
05:08 ---
Subject: Bug 20115

CVSROOT:/cvs/gcc
Module name:gcc
Changes by: [EMAIL PROTECTED]   2005-02-23 05:08:33

Modified files:
gcc: ChangeLog tree-optimize.c tree-pass.h 
 tree-ssa-alias.c tree-ssa-operands.c tree-ssa.c 
gcc/testsuite  : ChangeLog 
gcc/testsuite/gcc.dg/tree-ssa: 20040517-1.c 
Added files:
gcc/testsuite/gcc.dg: pr20100.c pr20115-1.c pr20115.c 

Log message:
PR tree-optimization/20100
PR tree-optimization/20115
* tree-optimize.c (init_tree_optimization_passes): Remove
pass_maybe_create_global_var.
* tree-pass.h (pass_maybe_create_global_var): Remove.
* tree-ssa-alias.c (aliases_computed_p): Declare.
(struct alias_info): Add field NUM_PURE_CONST_CALLS_FOUND.
(count_calls_and_maybe_create_global_var): Remove.
(pass_maybe_create_global_var): Remove.
(init_alias_info): Do not declare aliases_computed_p.
(maybe_create_global_var): If the function contains no
call-clobbered variables and a mix of pure/const and regular
function calls, create .GLOBAL_VAR.
Mark all call-clobbered variables for renaming.
(merge_pointed_to_info): Update comment.
(add_pointed_to_var): Likewise.
(is_escape_site): Likewise.
Accept struct alias_info * instead of size_t *.
Update all users.
Update AI-NUM_CALLS_FOUND and AI-NUM_PURE_CONST_CALLS_FOUND
as necessary.
* tree-ssa-operands.c (get_call_expr_operands): If
ALIASES_COMPUTED_P is false, do not add call-clobbering
operands.
* tree-ssa.c (init_tree_ssa): Set ALIASES_COMPUTED_P to false.
(delete_tree_ssa): Likewise.

testsuite/ChangeLog

PR tree-optimization/20100
PR tree-optimization/20115
* gcc.dg/pr20115.c: New test.
* gcc.dg/pr20115-1.c: New test.
* gcc.dg/pr20100.c: New test.
* gcc.dg/tree-ssa/20040517-1.c: Expect virtual operands for
call-clobbered variables after alias1.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gccr1=2.7566r2=2.7567
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-optimize.c.diff?cvsroot=gccr1=2.73r2=2.74
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-pass.h.diff?cvsroot=gccr1=2.26r2=2.27
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-alias.c.diff?cvsroot=gccr1=2.70r2=2.71
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-operands.c.diff?cvsroot=gccr1=2.62r2=2.63
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa.c.diff?cvsroot=gccr1=2.77r2=2.78
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gccr1=1.5071r2=1.5072
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20100.c.diff?cvsroot=gccr1=NONEr2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20115-1.c.diff?cvsroot=gccr1=NONEr2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr20115.c.diff?cvsroot=gccr1=NONEr2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c.diff?cvsroot=gccr1=1.3r2=1.4



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-21 Thread belyshev at depni dot sinp dot msu dot ru


-- 
   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed||1
  Known to fail||4.0.0
  Known to work||3.3.6 3.4.4
   Last reconfirmed|-00-00 00:00:00 |2005-02-22 07:28:59
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115


[Bug tree-optimization/20115] [4.0 Regression] Pure functions are mishandled

2005-02-20 Thread pinskia at gcc dot gnu dot org


-- 
   What|Removed |Added

Summary|[4.0 Regression] Pure   |[4.0 Regression] Pure
   |functions are missed handled|functions are mishandled


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20115