diff mbox

More tree-flow.h prototypes.

Message ID 524C1735.7070203@redhat.com
State New
Headers show

Commit Message

Andrew MacLeod Oct. 2, 2013, 12:53 p.m. UTC
On 10/02/2013 07:58 AM, Andrew MacLeod wrote:
> On 10/02/2013 04:37 AM, Richard Biener wrote:
>> On Tue, Oct 1, 2013 at 11:01 PM, Andrew MacLeod <amacleod@redhat.com> 
>> wrote:
>>> This patch moves prototypes into gimple-fold.h (which already existed).
>>> There were a few in tree-flow.h and a bunch in gimple.h. The 
>>> routines are
>>> used frequently enough that it makes sense to include gimple-fold.h 
>>> from
>>> gimple.h instead of from within each .c file that needs it. 
>>> (presumably why
>>> the prototypes were in gimple.h to begin with). I took gimple-fold.h 
>>> out of
>>> whatever .c files it was included in.
>>>
>>> tree-ssa-copy.h was also created for the prototypes in that file and
>>> included from tree-ssa.h.
>> These should probably be moved elsewhere (tree-ssa-copy.c is supposed
>> to be the copy propagation pass file).  But that can be done as 
>> followup.
>>
>>
> hmm, easy enough to move them *all* to tree-ssa-propagate.[ch] right 
> now and check it in...  That seems like the right place for all of 
> them and then we don't even need to create tree-ssa-copy.h...?
>
Like so..  and directly include tree-ssa-propagate.h in the 3 .c files 
that need it now.

bootstrapped on x86_64-unknown-linux-gnu.. regressions running. Prefer this?

Andrew

Comments

Richard Biener Oct. 2, 2013, 5:12 p.m. UTC | #1
Andrew MacLeod <amacleod@redhat.com> wrote:
>On 10/02/2013 07:58 AM, Andrew MacLeod wrote:
>> On 10/02/2013 04:37 AM, Richard Biener wrote:
>>> On Tue, Oct 1, 2013 at 11:01 PM, Andrew MacLeod
><amacleod@redhat.com> 
>>> wrote:
>>>> This patch moves prototypes into gimple-fold.h (which already
>existed).
>>>> There were a few in tree-flow.h and a bunch in gimple.h. The 
>>>> routines are
>>>> used frequently enough that it makes sense to include gimple-fold.h
>
>>>> from
>>>> gimple.h instead of from within each .c file that needs it. 
>>>> (presumably why
>>>> the prototypes were in gimple.h to begin with). I took
>gimple-fold.h 
>>>> out of
>>>> whatever .c files it was included in.
>>>>
>>>> tree-ssa-copy.h was also created for the prototypes in that file
>and
>>>> included from tree-ssa.h.
>>> These should probably be moved elsewhere (tree-ssa-copy.c is
>supposed
>>> to be the copy propagation pass file).  But that can be done as 
>>> followup.
>>>
>>>
>> hmm, easy enough to move them *all* to tree-ssa-propagate.[ch] right 
>> now and check it in...  That seems like the right place for all of 
>> them and then we don't even need to create tree-ssa-copy.h...?
>>
>Like so..  and directly include tree-ssa-propagate.h in the 3 .c files 
>that need it now.
>
>bootstrapped on x86_64-unknown-linux-gnu.. regressions running. Prefer
>this?

Yes.

Richard.
>Andrew
Tobias Burnus Oct. 2, 2013, 7:09 p.m. UTC | #2
This patch (rev. 203118) seems to break bootstrapping with Graphite:

g++ -c   -g -DIN_GCC   -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long 
-Wno-variadic-macros -Wno-overlength-strings -fno-common 
-DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include 
-I../../gcc/../libcpp/include  -I../../gcc/../libdecnumber 
-I../../gcc/../libdecnumber/bid -I../libdecnumber 
-I../../gcc/../libbacktrace -DCLOOG_INT_GMP    -o ipa-devirt.o -MT 
ipa-devirt.o -MMD -MP -MF ./.deps/ipa-devirt.TPo ../../gcc/ipa-devirt.c
../../gcc/graphite-sese-to-poly.c: In function 'void 
rewrite_cross_bb_scalar_dependence(scop_p, tree, tree, gimple)':
../../gcc/graphite-sese-to-poly.c:2348:31: error: 'replace_exp' was not 
declared in this scope
        replace_exp (use_p, name);
                                ^
../../gcc/graphite-scop-detection.c: In function 'void 
canonicalize_loop_closed_ssa(loop_p)':
../../gcc/graphite-scop-detection.c:1335:26: error: 'replace_exp' was 
not declared in this scope
    replace_exp (use_p, res);
                           ^
make[3]: *** [graphite-sese-to-poly.o] Error 1


Tobias

> 	* tree-flow.h: Remove some prototypes.
> 	* gimple-fold.h: Add prototypes from gimple.h and tree-flow.h.
> 	* tree-ssa-propagate.h: Relocate prototypes from tree-flow.h.
> 	* tree-ssa-copy.c (may_propagate*, propagate_value, replace_exp,
> 	propagate_tree_value*): Move from here to...
> 	* tree-ssa-propagate.c (may_propagate*, propagate_value, replace_exp,
> 	propagate_tree_value*): Relocate here.
> 	* tree-ssa-propagate:h: Relocate prototypes from tree-flow.h.
> 	* gimple.h: Include gimple-fold.h, move prototypes into gimple-fold.h.
> 	* gimple-fold.c: Remove gimple-fold.h from include list.
> 	* tree-vrp.c: Remove gimple-fold.h from include list.
> 	* tree-ssa-sccvn.c: Remove gimple-fold.h from include list.
> 	* tree-ssa-ccp.c: Remove gimple-fold.h from include list.
> 	* tree-scalar-evolution.c: Add tree-ssa-propagate.h to include list.
> 	* tree-ssa-pre.c: Add tree-ssa-propagate.h to include list.
> 	* sese.c: Add tree-ssa-propagate.h to include list.



Andrew MacLeod wrote:
> On 10/02/2013 07:58 AM, Andrew MacLeod wrote:
>> On 10/02/2013 04:37 AM, Richard Biener wrote:
>>> On Tue, Oct 1, 2013 at 11:01 PM, Andrew MacLeod <amacleod@redhat.com>
>>> wrote:
>>>> This patch moves prototypes into gimple-fold.h (which already existed).
>>>> There were a few in tree-flow.h and a bunch in gimple.h. The
>>>> routines are
>>>> used frequently enough that it makes sense to include gimple-fold.h
>>>> from
>>>> gimple.h instead of from within each .c file that needs it.
>>>> (presumably why
>>>> the prototypes were in gimple.h to begin with). I took gimple-fold.h
>>>> out of
>>>> whatever .c files it was included in.
>>>>
>>>> tree-ssa-copy.h was also created for the prototypes in that file and
>>>> included from tree-ssa.h.
>>> These should probably be moved elsewhere (tree-ssa-copy.c is supposed
>>> to be the copy propagation pass file).  But that can be done as
>>> followup.
>>>
>>>
>> hmm, easy enough to move them *all* to tree-ssa-propagate.[ch] right
>> now and check it in...  That seems like the right place for all of
>> them and then we don't even need to create tree-ssa-copy.h...?
>>
> Like so..  and directly include tree-ssa-propagate.h in the 3 .c files
> that need it now.
>
> bootstrapped on x86_64-unknown-linux-gnu.. regressions running. Prefer
> this?
>
> Andrew
Andrew MacLeod Oct. 2, 2013, 7:30 p.m. UTC | #3
On 10/02/2013 03:09 PM, Tobias Burnus wrote:
> This patch (rev. 203118) seems to break bootstrapping with Graphite:
>
> g++ -c   -g -DIN_GCC   -fno-exceptions -fno-rtti 
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
> -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long 
> -Wno-variadic-macros -Wno-overlength-strings -fno-common 
> -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. 
> -I../../gcc/../include -I../../gcc/../libcpp/include 
> -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid 
> -I../libdecnumber -I../../gcc/../libbacktrace -DCLOOG_INT_GMP -o 
> ipa-devirt.o -MT ipa-devirt.o -MMD -MP -MF ./.deps/ipa-devirt.TPo 
> ../../gcc/ipa-devirt.c
> ../../gcc/graphite-sese-to-poly.c: In function 'void 
> rewrite_cross_bb_scalar_dependence(scop_p, tree, tree, gimple)':
> ../../gcc/graphite-sese-to-poly.c:2348:31: error: 'replace_exp' was 
> not declared in this scope
>        replace_exp (use_p, name);
>                                ^
> ../../gcc/graphite-scop-detection.c: In function 'void 
> canonicalize_loop_closed_ssa(loop_p)':
> ../../gcc/graphite-scop-detection.c:1335:26: error: 'replace_exp' was 
> not declared in this scope
>    replace_exp (use_p, res);
>                           ^
> make[3]: *** [graphite-sese-to-poly.o] Error 1
>
>
> Tobias
>
>>     * tree-flow.h: Remove some prototypes.
>>     * gimple-fold.h: Add prototypes from gimple.h and tree-flow.h.
>>     * tree-ssa-propagate.h: Relocate prototypes from tree-flow.h.
>>     * tree-ssa-copy.c (may_propagate*, propagate_value, replace_exp,
>>     propagate_tree_value*): Move from here to...
>>     * tree-ssa-propagate.c (may_propagate*, propagate_value, 
>> replace_exp,
>>     propagate_tree_value*): Relocate here.
>>     * tree-ssa-propagate:h: Relocate prototypes from tree-flow.h.
>>     * gimple.h: Include gimple-fold.h, move prototypes into 
>> gimple-fold.h.
>>     * gimple-fold.c: Remove gimple-fold.h from include list.
>>     * tree-vrp.c: Remove gimple-fold.h from include list.
>>     * tree-ssa-sccvn.c: Remove gimple-fold.h from include list.
>>     * tree-ssa-ccp.c: Remove gimple-fold.h from include list.
>>     * tree-scalar-evolution.c: Add tree-ssa-propagate.h to include list.
>>     * tree-ssa-pre.c: Add tree-ssa-propagate.h to include list.
>>     * sese.c: Add tree-ssa-propagate.h to include list.
>

I did scratch rebuilds and didn't run into any problem.. and it compiles 
right now for me... hmmm

00000h,  I see, the entire file is wrapped by
#ifdef HAVE_cloog
<...>
#endif

so If I am compiling without cloog (which I am) then the entire file 
becomes basically nothing... and thus compiles fine.

I'm guessing graphite-sese-to-poly.c  has a similar problem since part 
of the file is wrapped like that...
That seems like a somewhat hazardous situation :-P.

anwyay, both files should have #include "tree-ssa-propagate.h" then I 
guess.  I don't have cloog so can't test it, can you verify that works?

Andrew
diff mbox

Patch



	* tree-flow.h: Remove some prototypes.
	* gimple-fold.h: Add prototypes from gimple.h and tree-flow.h.
	* tree-ssa-propagate.h: Relocate prototypes from tree-flow.h.
	* tree-ssa-copy.c (may_propagate*, propagate_value, replace_exp, 
	propagate_tree_value*): Move from here to...
	* tree-ssa-propagate.c (may_propagate*, propagate_value, replace_exp, 
	propagate_tree_value*): Relocate here.
	* tree-ssa-propagate:h: Relocate prototypes from tree-flow.h.
	* gimple.h: Include gimple-fold.h, move prototypes into gimple-fold.h.
	* gimple-fold.c: Remove gimple-fold.h from include list.
	* tree-vrp.c: Remove gimple-fold.h from include list.
	* tree-ssa-sccvn.c: Remove gimple-fold.h from include list.
	* tree-ssa-ccp.c: Remove gimple-fold.h from include list.
	* tree-scalar-evolution.c: Add tree-ssa-propagate.h to include list.
	* tree-ssa-pre.c: Add tree-ssa-propagate.h to include list.
	* sese.c: Add tree-ssa-propagate.h to include list.

Index: tree-flow.h
===================================================================
*** tree-flow.h	(revision 203085)
--- tree-flow.h	(working copy)
*************** void mark_virtual_operands_for_renaming 
*** 297,306 ****
  tree get_current_def (tree);
  void set_current_def (tree, tree);
  
- /* In tree-ssa-ccp.c  */
- tree fold_const_aggregate_ref (tree);
- tree gimple_fold_stmt_to_constant (gimple, tree (*)(tree));
- 
  /* In tree-ssa-dom.c  */
  extern void dump_dominator_optimization_stats (FILE *);
  extern void debug_dominator_optimization_stats (void);
--- 297,302 ----
*************** int loop_depth_of_name (tree);
*** 308,322 ****
  tree degenerate_phi_result (gimple);
  bool simple_iv_increment_p (gimple);
  
- /* In tree-ssa-copy.c  */
- extern void propagate_value (use_operand_p, tree);
- extern void propagate_tree_value (tree *, tree);
- extern void propagate_tree_value_into_stmt (gimple_stmt_iterator *, tree);
- extern void replace_exp (use_operand_p, tree);
- extern bool may_propagate_copy (tree, tree);
- extern bool may_propagate_copy_into_stmt (gimple, tree);
- extern bool may_propagate_copy_into_asm (tree);
- 
  /* In tree-ssa-loop-ch.c  */
  bool do_while_loop_p (struct loop *);
  
--- 304,309 ----
Index: gimple-fold.h
===================================================================
*** gimple-fold.h	(revision 203085)
--- gimple-fold.h	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 22,31 ****
  #ifndef GCC_GIMPLE_FOLD_H
  #define GCC_GIMPLE_FOLD_H
  
! tree fold_const_aggregate_ref_1 (tree, tree (*) (tree));
! tree fold_const_aggregate_ref (tree);
! 
! tree gimple_fold_stmt_to_constant_1 (gimple, tree (*) (tree));
! tree gimple_fold_stmt_to_constant (gimple, tree (*) (tree));
  
  #endif  /* GCC_GIMPLE_FOLD_H */
--- 22,43 ----
  #ifndef GCC_GIMPLE_FOLD_H
  #define GCC_GIMPLE_FOLD_H
  
! extern tree canonicalize_constructor_val (tree, tree);
! extern tree get_symbol_constant_value (tree);
! extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
! extern tree gimple_fold_builtin (gimple);
! extern tree gimple_extract_devirt_binfo_from_cst (tree, tree);
! extern bool fold_stmt (gimple_stmt_iterator *);
! extern bool fold_stmt_inplace (gimple_stmt_iterator *);
! extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree, 
! 					enum tree_code, tree, tree);
! extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
! 				       enum tree_code, tree, tree);
! extern tree gimple_fold_stmt_to_constant_1 (gimple, tree (*) (tree));
! extern tree gimple_fold_stmt_to_constant (gimple, tree (*) (tree));
! extern tree fold_const_aggregate_ref_1 (tree, tree (*) (tree));
! extern tree fold_const_aggregate_ref (tree);
! extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree);
! extern bool gimple_val_nonnegative_real_p (tree);
  
  #endif  /* GCC_GIMPLE_FOLD_H */
Index: tree-ssa-copy.c
===================================================================
*** tree-ssa-copy.c	(revision 203085)
--- tree-ssa-copy.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 50,269 ****
     replacements of one SSA_NAME with a different SSA_NAME to use the
     APIs defined in this file.  */
  
- /* Return true if we may propagate ORIG into DEST, false otherwise.  */
- 
- bool
- may_propagate_copy (tree dest, tree orig)
- {
-   tree type_d = TREE_TYPE (dest);
-   tree type_o = TREE_TYPE (orig);
- 
-   /* If ORIG flows in from an abnormal edge, it cannot be propagated.  */
-   if (TREE_CODE (orig) == SSA_NAME
-       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)
-       /* If it is the default definition and an automatic variable then
-          we can though and it is important that we do to avoid
- 	 uninitialized regular copies.  */
-       && !(SSA_NAME_IS_DEFAULT_DEF (orig)
- 	   && (SSA_NAME_VAR (orig) == NULL_TREE
- 	       || TREE_CODE (SSA_NAME_VAR (orig)) == VAR_DECL)))
-     return false;
- 
-   /* If DEST is an SSA_NAME that flows from an abnormal edge, then it
-      cannot be replaced.  */
-   if (TREE_CODE (dest) == SSA_NAME
-       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest))
-     return false;
- 
-   /* Do not copy between types for which we *do* need a conversion.  */
-   if (!useless_type_conversion_p (type_d, type_o))
-     return false;
- 
-   /* Generally propagating virtual operands is not ok as that may
-      create overlapping life-ranges.  */
-   if (TREE_CODE (dest) == SSA_NAME && virtual_operand_p (dest))
-     return false;
- 
-   /* Anything else is OK.  */
-   return true;
- }
- 
- /* Like may_propagate_copy, but use as the destination expression
-    the principal expression (typically, the RHS) contained in
-    statement DEST.  This is more efficient when working with the
-    gimple tuples representation.  */
- 
- bool
- may_propagate_copy_into_stmt (gimple dest, tree orig)
- {
-   tree type_d;
-   tree type_o;
- 
-   /* If the statement is a switch or a single-rhs assignment,
-      then the expression to be replaced by the propagation may
-      be an SSA_NAME.  Fortunately, there is an explicit tree
-      for the expression, so we delegate to may_propagate_copy.  */
- 
-   if (gimple_assign_single_p (dest))
-     return may_propagate_copy (gimple_assign_rhs1 (dest), orig);
-   else if (gimple_code (dest) == GIMPLE_SWITCH)
-     return may_propagate_copy (gimple_switch_index (dest), orig);
- 
-   /* In other cases, the expression is not materialized, so there
-      is no destination to pass to may_propagate_copy.  On the other
-      hand, the expression cannot be an SSA_NAME, so the analysis
-      is much simpler.  */
- 
-   if (TREE_CODE (orig) == SSA_NAME
-       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig))
-     return false;
- 
-   if (is_gimple_assign (dest))
-     type_d = TREE_TYPE (gimple_assign_lhs (dest));
-   else if (gimple_code (dest) == GIMPLE_COND)
-     type_d = boolean_type_node;
-   else if (is_gimple_call (dest)
-            && gimple_call_lhs (dest) != NULL_TREE)
-     type_d = TREE_TYPE (gimple_call_lhs (dest));
-   else
-     gcc_unreachable ();
- 
-   type_o = TREE_TYPE (orig);
- 
-   if (!useless_type_conversion_p (type_d, type_o))
-     return false;
- 
-   return true;
- }
- 
- /* Similarly, but we know that we're propagating into an ASM_EXPR.  */
- 
- bool
- may_propagate_copy_into_asm (tree dest ATTRIBUTE_UNUSED)
- {
-   return true;
- }
- 
- 
- /* Common code for propagate_value and replace_exp.
- 
-    Replace use operand OP_P with VAL.  FOR_PROPAGATION indicates if the
-    replacement is done to propagate a value or not.  */
- 
- static void
- replace_exp_1 (use_operand_p op_p, tree val,
-     	       bool for_propagation ATTRIBUTE_UNUSED)
- {
- #if defined ENABLE_CHECKING
-   tree op = USE_FROM_PTR (op_p);
- 
-   gcc_assert (!(for_propagation
- 		&& TREE_CODE (op) == SSA_NAME
- 		&& TREE_CODE (val) == SSA_NAME
- 		&& !may_propagate_copy (op, val)));
- #endif
- 
-   if (TREE_CODE (val) == SSA_NAME)
-     SET_USE (op_p, val);
-   else
-     SET_USE (op_p, unshare_expr (val));
- }
- 
- 
- /* Propagate the value VAL (assumed to be a constant or another SSA_NAME)
-    into the operand pointed to by OP_P.
- 
-    Use this version for const/copy propagation as it will perform additional
-    checks to ensure validity of the const/copy propagation.  */
- 
- void
- propagate_value (use_operand_p op_p, tree val)
- {
-   replace_exp_1 (op_p, val, true);
- }
- 
- /* Replace *OP_P with value VAL (assumed to be a constant or another SSA_NAME).
- 
-    Use this version when not const/copy propagating values.  For example,
-    PRE uses this version when building expressions as they would appear
-    in specific blocks taking into account actions of PHI nodes.
- 
-    The statement in which an expression has been replaced should be
-    folded using fold_stmt_inplace.  */
- 
- void
- replace_exp (use_operand_p op_p, tree val)
- {
-   replace_exp_1 (op_p, val, false);
- }
- 
- 
- /* Propagate the value VAL (assumed to be a constant or another SSA_NAME)
-    into the tree pointed to by OP_P.
- 
-    Use this version for const/copy propagation when SSA operands are not
-    available.  It will perform the additional checks to ensure validity of
-    the const/copy propagation, but will not update any operand information.
-    Be sure to mark the stmt as modified.  */
- 
- void
- propagate_tree_value (tree *op_p, tree val)
- {
-   gcc_checking_assert (!(TREE_CODE (val) == SSA_NAME
- 			 && *op_p
- 			 && TREE_CODE (*op_p) == SSA_NAME
- 			 && !may_propagate_copy (*op_p, val)));
- 
-   if (TREE_CODE (val) == SSA_NAME)
-     *op_p = val;
-   else
-     *op_p = unshare_expr (val);
- }
- 
- 
- /* Like propagate_tree_value, but use as the operand to replace
-    the principal expression (typically, the RHS) contained in the
-    statement referenced by iterator GSI.  Note that it is not
-    always possible to update the statement in-place, so a new
-    statement may be created to replace the original.  */
- 
- void
- propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
- {
-   gimple stmt = gsi_stmt (*gsi);
- 
-   if (is_gimple_assign (stmt))
-     {
-       tree expr = NULL_TREE;
-       if (gimple_assign_single_p (stmt))
-         expr = gimple_assign_rhs1 (stmt);
-       propagate_tree_value (&expr, val);
-       gimple_assign_set_rhs_from_tree (gsi, expr);
-     }
-   else if (gimple_code (stmt) == GIMPLE_COND)
-     {
-       tree lhs = NULL_TREE;
-       tree rhs = build_zero_cst (TREE_TYPE (val));
-       propagate_tree_value (&lhs, val);
-       gimple_cond_set_code (stmt, NE_EXPR);
-       gimple_cond_set_lhs (stmt, lhs);
-       gimple_cond_set_rhs (stmt, rhs);
-     }
-   else if (is_gimple_call (stmt)
-            && gimple_call_lhs (stmt) != NULL_TREE)
-     {
-       tree expr = NULL_TREE;
-       bool res;
-       propagate_tree_value (&expr, val);
-       res = update_call_from_tree (gsi, expr);
-       gcc_assert (res);
-     }
-   else if (gimple_code (stmt) == GIMPLE_SWITCH)
-     propagate_tree_value (gimple_switch_index_ptr (stmt), val);
-   else
-     gcc_unreachable ();
- }
- 
  /*---------------------------------------------------------------------------
  				Copy propagation
  ---------------------------------------------------------------------------*/
--- 50,55 ----
Index: tree-ssa-propagate.c
===================================================================
*** tree-ssa-propagate.c	(revision 203085)
--- tree-ssa-propagate.c	(working copy)
*************** substitute_and_fold (ssa_prop_get_value_
*** 1226,1229 ****
--- 1226,1444 ----
    return something_changed;
  }
  
+ 
+ /* Return true if we may propagate ORIG into DEST, false otherwise.  */
+ 
+ bool
+ may_propagate_copy (tree dest, tree orig)
+ {
+   tree type_d = TREE_TYPE (dest);
+   tree type_o = TREE_TYPE (orig);
+ 
+   /* If ORIG flows in from an abnormal edge, it cannot be propagated.  */
+   if (TREE_CODE (orig) == SSA_NAME
+       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)
+       /* If it is the default definition and an automatic variable then
+          we can though and it is important that we do to avoid
+ 	 uninitialized regular copies.  */
+       && !(SSA_NAME_IS_DEFAULT_DEF (orig)
+ 	   && (SSA_NAME_VAR (orig) == NULL_TREE
+ 	       || TREE_CODE (SSA_NAME_VAR (orig)) == VAR_DECL)))
+     return false;
+ 
+   /* If DEST is an SSA_NAME that flows from an abnormal edge, then it
+      cannot be replaced.  */
+   if (TREE_CODE (dest) == SSA_NAME
+       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest))
+     return false;
+ 
+   /* Do not copy between types for which we *do* need a conversion.  */
+   if (!useless_type_conversion_p (type_d, type_o))
+     return false;
+ 
+   /* Generally propagating virtual operands is not ok as that may
+      create overlapping life-ranges.  */
+   if (TREE_CODE (dest) == SSA_NAME && virtual_operand_p (dest))
+     return false;
+ 
+   /* Anything else is OK.  */
+   return true;
+ }
+ 
+ /* Like may_propagate_copy, but use as the destination expression
+    the principal expression (typically, the RHS) contained in
+    statement DEST.  This is more efficient when working with the
+    gimple tuples representation.  */
+ 
+ bool
+ may_propagate_copy_into_stmt (gimple dest, tree orig)
+ {
+   tree type_d;
+   tree type_o;
+ 
+   /* If the statement is a switch or a single-rhs assignment,
+      then the expression to be replaced by the propagation may
+      be an SSA_NAME.  Fortunately, there is an explicit tree
+      for the expression, so we delegate to may_propagate_copy.  */
+ 
+   if (gimple_assign_single_p (dest))
+     return may_propagate_copy (gimple_assign_rhs1 (dest), orig);
+   else if (gimple_code (dest) == GIMPLE_SWITCH)
+     return may_propagate_copy (gimple_switch_index (dest), orig);
+ 
+   /* In other cases, the expression is not materialized, so there
+      is no destination to pass to may_propagate_copy.  On the other
+      hand, the expression cannot be an SSA_NAME, so the analysis
+      is much simpler.  */
+ 
+   if (TREE_CODE (orig) == SSA_NAME
+       && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig))
+     return false;
+ 
+   if (is_gimple_assign (dest))
+     type_d = TREE_TYPE (gimple_assign_lhs (dest));
+   else if (gimple_code (dest) == GIMPLE_COND)
+     type_d = boolean_type_node;
+   else if (is_gimple_call (dest)
+            && gimple_call_lhs (dest) != NULL_TREE)
+     type_d = TREE_TYPE (gimple_call_lhs (dest));
+   else
+     gcc_unreachable ();
+ 
+   type_o = TREE_TYPE (orig);
+ 
+   if (!useless_type_conversion_p (type_d, type_o))
+     return false;
+ 
+   return true;
+ }
+ 
+ /* Similarly, but we know that we're propagating into an ASM_EXPR.  */
+ 
+ bool
+ may_propagate_copy_into_asm (tree dest ATTRIBUTE_UNUSED)
+ {
+   return true;
+ }
+ 
+ 
+ /* Common code for propagate_value and replace_exp.
+ 
+    Replace use operand OP_P with VAL.  FOR_PROPAGATION indicates if the
+    replacement is done to propagate a value or not.  */
+ 
+ static void
+ replace_exp_1 (use_operand_p op_p, tree val,
+     	       bool for_propagation ATTRIBUTE_UNUSED)
+ {
+ #if defined ENABLE_CHECKING
+   tree op = USE_FROM_PTR (op_p);
+ 
+   gcc_assert (!(for_propagation
+ 		&& TREE_CODE (op) == SSA_NAME
+ 		&& TREE_CODE (val) == SSA_NAME
+ 		&& !may_propagate_copy (op, val)));
+ #endif
+ 
+   if (TREE_CODE (val) == SSA_NAME)
+     SET_USE (op_p, val);
+   else
+     SET_USE (op_p, unshare_expr (val));
+ }
+ 
+ 
+ /* Propagate the value VAL (assumed to be a constant or another SSA_NAME)
+    into the operand pointed to by OP_P.
+ 
+    Use this version for const/copy propagation as it will perform additional
+    checks to ensure validity of the const/copy propagation.  */
+ 
+ void
+ propagate_value (use_operand_p op_p, tree val)
+ {
+   replace_exp_1 (op_p, val, true);
+ }
+ 
+ /* Replace *OP_P with value VAL (assumed to be a constant or another SSA_NAME).
+ 
+    Use this version when not const/copy propagating values.  For example,
+    PRE uses this version when building expressions as they would appear
+    in specific blocks taking into account actions of PHI nodes.
+ 
+    The statement in which an expression has been replaced should be
+    folded using fold_stmt_inplace.  */
+ 
+ void
+ replace_exp (use_operand_p op_p, tree val)
+ {
+   replace_exp_1 (op_p, val, false);
+ }
+ 
+ 
+ /* Propagate the value VAL (assumed to be a constant or another SSA_NAME)
+    into the tree pointed to by OP_P.
+ 
+    Use this version for const/copy propagation when SSA operands are not
+    available.  It will perform the additional checks to ensure validity of
+    the const/copy propagation, but will not update any operand information.
+    Be sure to mark the stmt as modified.  */
+ 
+ void
+ propagate_tree_value (tree *op_p, tree val)
+ {
+   gcc_checking_assert (!(TREE_CODE (val) == SSA_NAME
+ 			 && *op_p
+ 			 && TREE_CODE (*op_p) == SSA_NAME
+ 			 && !may_propagate_copy (*op_p, val)));
+ 
+   if (TREE_CODE (val) == SSA_NAME)
+     *op_p = val;
+   else
+     *op_p = unshare_expr (val);
+ }
+ 
+ 
+ /* Like propagate_tree_value, but use as the operand to replace
+    the principal expression (typically, the RHS) contained in the
+    statement referenced by iterator GSI.  Note that it is not
+    always possible to update the statement in-place, so a new
+    statement may be created to replace the original.  */
+ 
+ void
+ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
+ {
+   gimple stmt = gsi_stmt (*gsi);
+ 
+   if (is_gimple_assign (stmt))
+     {
+       tree expr = NULL_TREE;
+       if (gimple_assign_single_p (stmt))
+         expr = gimple_assign_rhs1 (stmt);
+       propagate_tree_value (&expr, val);
+       gimple_assign_set_rhs_from_tree (gsi, expr);
+     }
+   else if (gimple_code (stmt) == GIMPLE_COND)
+     {
+       tree lhs = NULL_TREE;
+       tree rhs = build_zero_cst (TREE_TYPE (val));
+       propagate_tree_value (&lhs, val);
+       gimple_cond_set_code (stmt, NE_EXPR);
+       gimple_cond_set_lhs (stmt, lhs);
+       gimple_cond_set_rhs (stmt, rhs);
+     }
+   else if (is_gimple_call (stmt)
+            && gimple_call_lhs (stmt) != NULL_TREE)
+     {
+       tree expr = NULL_TREE;
+       bool res;
+       propagate_tree_value (&expr, val);
+       res = update_call_from_tree (gsi, expr);
+       gcc_assert (res);
+     }
+   else if (gimple_code (stmt) == GIMPLE_SWITCH)
+     propagate_tree_value (gimple_switch_index_ptr (stmt), val);
+   else
+     gcc_unreachable ();
+ }
+ 
  #include "gt-tree-ssa-propagate.h"
Index: tree-ssa-propagate.h
===================================================================
*** tree-ssa-propagate.h	(revision 203085)
--- tree-ssa-propagate.h	(working copy)
*************** typedef bool (*ssa_prop_fold_stmt_fn) (g
*** 68,80 ****
  typedef tree (*ssa_prop_get_value_fn) (tree);
  
  
! /* In tree-ssa-propagate.c  */
! void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
! bool valid_gimple_rhs_p (tree);
! void move_ssa_defining_stmt_for_defs (gimple, gimple);
! bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
! bool update_call_from_tree (gimple_stmt_iterator *, tree);
! bool stmt_makes_single_store (gimple);
! bool substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn, bool);
  
  #endif /* _TREE_SSA_PROPAGATE_H  */
--- 68,87 ----
  typedef tree (*ssa_prop_get_value_fn) (tree);
  
  
! extern bool valid_gimple_rhs_p (tree);
! extern void move_ssa_defining_stmt_for_defs (gimple, gimple);
! extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
! extern bool update_call_from_tree (gimple_stmt_iterator *, tree);
! extern void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
! extern bool stmt_makes_single_store (gimple);
! extern bool substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn,
! 				 bool);
! extern bool may_propagate_copy (tree, tree);
! extern bool may_propagate_copy_into_stmt (gimple, tree);
! extern bool may_propagate_copy_into_asm (tree);
! extern void propagate_value (use_operand_p, tree);
! extern void replace_exp (use_operand_p, tree);
! extern void propagate_tree_value (tree *, tree);
! extern void propagate_tree_value_into_stmt (gimple_stmt_iterator *, tree);
  
  #endif /* _TREE_SSA_PROPAGATE_H  */
Index: gimple.h
===================================================================
*** gimple.h	(revision 203085)
--- gimple.h	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 30,35 ****
--- 30,36 ----
  #include "tree.h"
  #include "tree-ssa-alias.h"
  #include "internal-fn.h"
+ #include "gimple-fold.h"
  
  typedef gimple gimple_seq_node;
  
*************** unsigned get_gimple_rhs_num_ops (enum tr
*** 833,840 ****
  #define gimple_alloc(c, n) gimple_alloc_stat (c, n MEM_STAT_INFO)
  gimple gimple_alloc_stat (enum gimple_code, unsigned MEM_STAT_DECL);
  const char *gimple_decl_printable_name (tree, int);
- tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree);
- tree gimple_extract_devirt_binfo_from_cst (tree, tree);
  
  /* Returns true iff T is a scalar register variable.  */
  extern bool is_gimple_reg (tree);
--- 834,839 ----
*************** gimple_alloc_kind (enum gimple_code code
*** 5421,5441 ****
  
  extern void dump_gimple_statistics (void);
  
- /* In gimple-fold.c.  */
- void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
- tree gimple_fold_builtin (gimple);
- bool fold_stmt (gimple_stmt_iterator *);
- bool fold_stmt_inplace (gimple_stmt_iterator *);
- tree get_symbol_constant_value (tree);
- tree canonicalize_constructor_val (tree, tree);
- extern tree maybe_fold_and_comparisons (enum tree_code, tree, tree, 
- 					enum tree_code, tree, tree);
- extern tree maybe_fold_or_comparisons (enum tree_code, tree, tree,
- 				       enum tree_code, tree, tree);
- 
- bool gimple_val_nonnegative_real_p (tree);
- 
- 
  /* Set the location of all statements in SEQ to LOC.  */
  
  static inline void
--- 5420,5425 ----
Index: gimple-fold.c
===================================================================
*** gimple-fold.c	(revision 203085)
--- gimple-fold.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 29,35 ****
  #include "tree-ssa.h"
  #include "tree-ssa-propagate.h"
  #include "target.h"
- #include "gimple-fold.h"
  #include "ipa-utils.h"
  #include "gimple-pretty-print.h"
  
--- 29,34 ----
Index: tree-vrp.c
===================================================================
*** tree-vrp.c	(revision 203085)
--- tree-vrp.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 37,43 ****
  #include "tree-ssa-propagate.h"
  #include "tree-chrec.h"
  #include "tree-ssa-threadupdate.h"
- #include "gimple-fold.h"
  #include "expr.h"
  #include "optabs.h"
  
--- 37,42 ----
Index: tree-ssa-sccvn.c
===================================================================
*** tree-ssa-sccvn.c	(revision 203085)
--- tree-ssa-sccvn.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 37,43 ****
  #include "params.h"
  #include "tree-ssa-propagate.h"
  #include "tree-ssa-sccvn.h"
- #include "gimple-fold.h"
  
  /* This algorithm is based on the SCC algorithm presented by Keith
     Cooper and L. Taylor Simpson in "SCC-Based Value numbering"
--- 37,42 ----
Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c	(revision 203085)
--- tree-ssa-ccp.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 127,133 ****
  #include "target.h"
  #include "diagnostic-core.h"
  #include "dbgcnt.h"
- #include "gimple-fold.h"
  #include "params.h"
  #include "hash-table.h"
  
--- 127,132 ----
Index: tree-scalar-evolution.c
===================================================================
*** tree-scalar-evolution.c	(revision 203085)
--- tree-scalar-evolution.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 264,269 ****
--- 264,270 ----
  #include "tree-scalar-evolution.h"
  #include "dumpfile.h"
  #include "params.h"
+ #include "tree-ssa-propagate.h"
  
  static tree analyze_scalar_evolution_1 (struct loop *, tree, tree);
  static tree analyze_scalar_evolution_for_address_of (struct loop *loop,
Index: tree-ssa-pre.c
===================================================================
*** tree-ssa-pre.c	(revision 203085)
--- tree-ssa-pre.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 44,49 ****
--- 44,50 ----
  #include "dbgcnt.h"
  #include "domwalk.h"
  #include "ipa-prop.h"
+ #include "tree-ssa-propagate.h"
  
  /* TODO:
  
Index: sese.c
===================================================================
*** sese.c	(revision 203085)
--- sese.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 32,37 ****
--- 32,38 ----
  #include "tree-pass.h"
  #include "value-prof.h"
  #include "sese.h"
+ #include "tree-ssa-propagate.h"
  
  /* Print to stderr the element ELT.  */