[Bug tree-optimization/29738] Missed constant propagation into loops
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738 Andrew Pinski changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|--- |9.0 --- Comment #14 from Andrew Pinski --- (In reply to Richard Biener from comment #13) > A case predicated VN should handle. Fixed in GCC 9 with r9-2635
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #13 from rguenth at gcc dot gnu dot org 2010-04-07 12:21 --- A case predicated VN should handle. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||matz at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #12 from rguenth at gcc dot gnu dot org 2008-08-19 15:02 --- Disabled/xfailed with URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=139234 Log: 2008-08-19 Richard Guenther [EMAIL PROTECTED] * passes.c (init_optimization_passes): Exchange store-ccp with a ccp pass. * gcc.dg/tree-ssa/ssa-ccp-14.c: XFAIL. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Severity|normal |enhancement Status|RESOLVED|REOPENED Keywords||xfail Resolution|FIXED | Target Milestone|4.3.0 |--- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
-- rguenth at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|rakdver at gcc dot gnu dot |unassigned at gcc dot gnu |org |dot org Status|REOPENED|NEW http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #12 from chaoyingfu at gcc dot gnu dot org 2006-12-01 00:35 --- Subject: Bug 29738 Author: chaoyingfu Date: Fri Dec 1 00:32:38 2006 New Revision: 119391 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=119391 Log: Merged revisions 118545-118650 via svnmerge from svn+ssh://[EMAIL PROTECTED]/svn/gcc/trunk r118545 | burnus | 2006-11-07 05:27:53 -0800 (Tue, 07 Nov 2006) | 29 lines fortran/ 2006-11-06 Tobias Burnus [EMAIL PROTECTED] PR fortran/29601 * symbol.c (check_conflict, gfc_add_volatile): Add volatile support. * decl.c (match_attr_spec, gfc_match_volatile): Add volatile support. * gfortran.h (symbol_attribute): Add volatile_ to struct. * resolve.c (was_declared): Add volatile support. * trans-decl.c (gfc_finish_var_decl): Add volatile support. * match.h: Declare gfc_match_volatile. * parse.c (decode_statement): Recognize volatile. * modules.c (ab_attribute, attr_bits, mio_symbol_attribute): Add volatile support. * dump-parse-tree.c (gfc_show_attr): Add volatile support. testsuite/ 2006-11-06 Tobias Burnus [EMAIL PROTECTED] PR fortran/29601 * gfortran.dg/volatile.f90: Add. * gfortran.dg/volatile2.f90: Add. * gfortran.dg/volatile3.f90: Add. * gfortran.dg/volatile4.f90: Add. * gfortran.dg/volatile5.f90: Add. * gfortran.dg/volatile6.f90: Add. * gfortran.dg/volatile7.f90: Add. r118546 | davidu | 2006-11-07 06:08:55 -0800 (Tue, 07 Nov 2006) | 3 lines * config/mips/mips.h (ISA_HAS_PREFETCHX): Add ISA_MIPS32R2 to the list. r118547 | jiez | 2006-11-07 06:24:58 -0800 (Tue, 07 Nov 2006) | 3 lines * gcc.c (process_command): Treat -b as normal switch if its argument has no dash. r118550 | davidu | 2006-11-07 06:28:08 -0800 (Tue, 07 Nov 2006) | 5 lines * config/mips/mips.c (mips_rtx_cost_optimize_size): New table of costs when optimizing for size. (override_options): Use mips_rtx_cost_optimize_size table for cost calculations. r118552 | jules | 2006-11-07 07:16:07 -0800 (Tue, 07 Nov 2006) | 6 lines * floatformat.c (get_field): Fix segfault with little-endian word order on 64-bit hosts. (put_field): Likewise. (min): Move definition. r118553 | pault | 2006-11-07 07:17:17 -0800 (Tue, 07 Nov 2006) | 17 lines 2006-11-07 Paul Thomas [EMAIL PROTECTED] PR fortran/29539 PR fortran/29634 * decl.c (variable_decl): Add test for presence of proc_name. * error.c (gfc_error_flag_test): New function. * gfortran.h : Prototype for gfc_error_flag_test. 2006-11-07 Paul Thomas [EMAIL PROTECTED] PR fortran/29539 * gfortran.dg/gfortran.dg/blockdata_3.f90: New test. PR fortran/29634 * gfortran.dg/gfortran.dg/derived_function_interface_1.f90: New test. r118554 | bkoz | 2006-11-07 08:55:49 -0800 (Tue, 07 Nov 2006) | 49 lines 2006-11-07 Benjamin Kosnik [EMAIL PROTECTED] * include/ext/pb_ds/exception.hpp (pb_ds): Modify for -fno-exceptions. (__throw_container_error): New. Conditionalize based on __EXCEPTIONS. (__throw_insert_error): New. (__throw_join_error): New. (__throw_resize_error): New. * include/ext/pb_ds/detail/resize_policy/ hash_prime_size_policy_imp.hpp: Use them. * include/ext/pb_ds/detail/resize_policy/ hash_exponential_size_policy_imp.hpp: Same. * include/ext/pb_ds/detail/resize_policy/ hash_load_check_resize_trigger_imp.hpp: Same. * include/ext/pb_ds/detail/resize_policy/ hash_standard_resize_policy_imp.hpp: Same. * include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp * include/ext/pb_ds/detail/cc_hash_table_map_/ constructor_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp * include/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp * include/ext/pb_ds/detail/pat_trie_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/ constructors_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/bin_search_tree_/ split_join_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/ insert_no_store_hash_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/ resize_store_hash_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/ insert_store_hash_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/ constructor_destructor_fn_imps.hpp: Same. * include/ext/pb_ds/detail/gp_hash_table_map_/ resize_no_store_hash_fn_imps.hpp: Same.
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #11 from rguenth at gcc dot gnu dot org 2006-11-11 12:54 --- Fixed on the mainline. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution||FIXED Target Milestone|--- |4.3.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #10 from rakdver at gcc dot gnu dot org 2006-11-09 00:09 --- Subject: Bug 29738 Author: rakdver Date: Thu Nov 9 00:09:43 2006 New Revision: 118602 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=118602 Log: PR tree-optimization/29738 * tree-ssa-ccp.c: Remove UNKNOWN_VAL from comments. (ccp_lattice_t): Remove UNKNOWN_VAL. (dump_lattice_value, ccp_lattice_meet, ccp_visit_phi_node): Do not handle UNKNOWN_VAL. (get_default_value): Set initial value of virtual operands to VARYING. (get_value): Always use get_default_value on uninitialized operands. (set_value_varying, surely_varying_stmt_p): New functions. (set_lattice_value): Do not pass argument to get_value. Do not handle UNKNOWN_VAL. (likely_value): Follow the semantics described in the comment. (ccp_initialize): Use surely_varying_stmt_p. Do not mark phi nodes DONT_SIMULATE_AGAIN. (ccp_fold): Do not pass argument to get_value. (fold_const_aggregate_ref, visit_assignment): Ditto. Do not handle UNKNOWN_VAL. * gcc.dg/tree-ssa/ssa-ccp-14.c: New test. * gcc.dg/tree-ssa/ssa-ccp-15.c: New test. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-14.c trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-15.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-ccp.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #9 from rakdver at gcc dot gnu dot org 2006-11-07 10:55 --- Ah, I see. You are of course completely right. Now the question is, why does store_ccp not handle it? (Maybe it is as dis-functional as store_copyprop was until I fixed it?) I ended up rewriting large parts of store_ccp, so this indeed might be the case (I am testing the patch now). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #1 from sebastian dot pop at cri dot ensmp dot fr 2006-11-06 11:48 --- Subject: Re: Missed constant propagation into loops I think the problem is that i is a global variable and thus foo is potentially considered as modifying i. Have you tried void foo (void); void bar (void) { int i, j; i = 0; for (j = 0; j 1; j++) if (i) foo (); } This should be a simpler case that either is correctly simplified or I know what to do for making it work. For the original problem, why don't we propagate constants in # i_3 = V_MUST_DEF i_2; i = 0; # NONLOCAL.6_19 = PHI NONLOCAL.6_9(5), NONLOCAL.6_11(2); # i_18 = PHI i_7(5), i_3(2); i.e. replacing the use of i_3 with just the constant 0? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #2 from rakdver at gcc dot gnu dot org 2006-11-06 11:51 --- Have you tried void foo (void); void bar (void) { int i, j; i = 0; for (j = 0; j 1; j++) if (i) foo (); } This would work, obviously. For the original problem, why don't we propagate constants in # i_3 = V_MUST_DEF i_2; i = 0; # NONLOCAL.6_19 = PHI NONLOCAL.6_9(5), NONLOCAL.6_11(2); # i_18 = PHI i_7(5), i_3(2); i.e. replacing the use of i_3 with just the constant 0? Because i is a virtual operand, not real one. CCP could probably be taught to handle this case, I will check how difficult that would be. -- rakdver at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |rakdver at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2006-11-06 11:51:38 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #3 from rguenther at suse dot de 2006-11-06 12:04 --- Subject: Re: Missed constant propagation into loops On Mon, 6 Nov 2006, rakdver at gcc dot gnu dot org wrote: --- Comment #2 from rakdver at gcc dot gnu dot org 2006-11-06 11:51 --- Have you tried void foo (void); void bar (void) { int i, j; i = 0; for (j = 0; j 1; j++) if (i) foo (); } This would work, obviously. For the original problem, why don't we propagate constants in # i_3 = V_MUST_DEF i_2; i = 0; # NONLOCAL.6_19 = PHI NONLOCAL.6_9(5), NONLOCAL.6_11(2); # i_18 = PHI i_7(5), i_3(2); i.e. replacing the use of i_3 with just the constant 0? Because i is a virtual operand, not real one. But that doesn't help that i is loop-carried and so we don't propagate it to the if () stmt - we use i_18 there. Or am I missing something? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #4 from rguenth at gcc dot gnu dot org 2006-11-06 12:07 --- Btw, store_ccp should catch the propagation to the PHI node, but somehow it doesn't. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #5 from rakdver at atrey dot karlin dot mff dot cuni dot cz 2006-11-06 12:08 --- Subject: Re: Missed constant propagation into loops --- Comment #2 from rakdver at gcc dot gnu dot org 2006-11-06 11:51 --- Have you tried void foo (void); void bar (void) { int i, j; i = 0; for (j = 0; j 1; j++) if (i) foo (); } This would work, obviously. For the original problem, why don't we propagate constants in # i_3 = V_MUST_DEF i_2; i = 0; # NONLOCAL.6_19 = PHI NONLOCAL.6_9(5), NONLOCAL.6_11(2); # i_18 = PHI i_7(5), i_3(2); i.e. replacing the use of i_3 with just the constant 0? Because i is a virtual operand, not real one. But that doesn't help that i is loop-carried and so we don't propagate it to the if () stmt - we use i_18 there. Or am I missing something? ccp can handle this for real operands. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #6 from rguenth at gcc dot gnu dot org 2006-11-06 12:18 --- But obviously for real operands, foo () won't clobber them. I.e. the following also could be optimized but is not: void foo (int *); void bar (void) { int j; int i; i = 0; for (j = 0; j 1; j++) if (i) foo (i); } foo () will be never executed, so the clobbering of i is not executed, so we don't need i as PHI arg/result for the loop. This is what I'm looking for as optimization. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #7 from rakdver at atrey dot karlin dot mff dot cuni dot cz 2006-11-06 12:33 --- Subject: Re: Missed constant propagation into loops But obviously for real operands, foo () won't clobber them. I.e. the following also could be optimized but is not: void foo (int *); void bar (void) { int j; int i; i = 0; for (j = 0; j 1; j++) if (i) foo (i); } foo () will be never executed, so the clobbering of i is not executed, so we don't need i as PHI arg/result for the loop. This is what I'm looking for as optimization. now you have lost me, I have no idea what you are trying to tell. What I mean is that this is exactly the same case like void bar (void) { int j; int i; i = 0; for (j = 0; j 1; j++) if (i) i = 1; } Except that in the testcase for the PR, i is not a real operand. Since we already have some support for virtual operands in ccp, it should not be too difficult to make it handle this case as well. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738
[Bug tree-optimization/29738] Missed constant propagation into loops
--- Comment #8 from rguenther at suse dot de 2006-11-06 12:37 --- Subject: Re: Missed constant propagation into loops On Mon, 6 Nov 2006, rakdver at atrey dot karlin dot mff dot cuni dot cz wrote: --- Comment #7 from rakdver at atrey dot karlin dot mff dot cuni dot cz 2006-11-06 12:33 --- Subject: Re: Missed constant propagation into loops But obviously for real operands, foo () won't clobber them. I.e. the following also could be optimized but is not: void foo (int *); void bar (void) { int j; int i; i = 0; for (j = 0; j 1; j++) if (i) foo (i); } foo () will be never executed, so the clobbering of i is not executed, so we don't need i as PHI arg/result for the loop. This is what I'm looking for as optimization. now you have lost me, I have no idea what you are trying to tell. What I mean is that this is exactly the same case like void bar (void) { int j; int i; i = 0; for (j = 0; j 1; j++) if (i) i = 1; } Except that in the testcase for the PR, i is not a real operand. Since we already have some support for virtual operands in ccp, it should not be too difficult to make it handle this case as well. Ah, I see. You are of course completely right. Now the question is, why does store_ccp not handle it? (Maybe it is as dis-functional as store_copyprop was until I fixed it?) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738