This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pretty-ipa merge 16: Fix ipa-pure-const to not mark looping-pure/const as finite


Hi,
ipa-pure-const assumes it was run just once in a way that
state_set_in_source is implying non-loopingness.  This is wrong
when looping pure/const functions was prevoiusly detected and we 
run the pass that would currently end up marking the function as
non-loopig.

This patch renames the existing field to state_previously_known and
adds new looping_previously_known that are used accordingly.

Bootstrapped/regtested x86_64-linux and comitted.

2009-04-27  Jan Hubicka  <jh@suse.cz>

	* ipa-pure-const.c (struct funct_state_d): New fields
	state_previously_known, looping_previously_known; remove
	state_set_in_source.
	(analyze_function): Use new fields.
	(propagate): Avoid assumption that state_set_in_source imply
	nonlooping.
Index: ipa-pure-const.c
===================================================================
*** ipa-pure-const.c	(revision 146776)
--- ipa-pure-const.c	(working copy)
*************** struct funct_state_d 
*** 72,78 ****
    /* See above.  */
    enum pure_const_state_e pure_const_state;
    /* What user set here; we can be always sure about this.  */
!   enum pure_const_state_e state_set_in_source; 
  
    /* True if the function could possibly infinite loop.  There are a
       lot of ways that this could be determined.  We are pretty
--- 72,79 ----
    /* See above.  */
    enum pure_const_state_e pure_const_state;
    /* What user set here; we can be always sure about this.  */
!   enum pure_const_state_e state_previously_known; 
!   bool looping_previously_known; 
  
    /* True if the function could possibly infinite loop.  There are a
       lot of ways that this could be determined.  We are pretty
*************** analyze_function (struct cgraph_node *fn
*** 485,491 ****
  
    l = XCNEW (struct funct_state_d);
    l->pure_const_state = IPA_CONST;
!   l->state_set_in_source = IPA_NEITHER;
    L->looping = false;
    l->can_throw = false;
  
--- 486,493 ----
  
    l = XCNEW (struct funct_state_d);
    l->pure_const_state = IPA_CONST;
!   l->state_previously_known = IPA_NEITHER;
!   l->looping_previously_known = true;
    l->looping = false;
    l->can_throw = false;
  
*************** end:
*** 528,544 ****
    if (TREE_READONLY (decl))
      {
        l->pure_const_state = IPA_CONST;
!       l->state_set_in_source = IPA_CONST;
        if (!DECL_LOOPING_CONST_OR_PURE_P (decl))
!         l->looping = false;
      }
    if (DECL_PURE_P (decl))
      {
        if (l->pure_const_state != IPA_CONST)
          l->pure_const_state = IPA_PURE;
!       l->state_set_in_source = IPA_PURE;
        if (!DECL_LOOPING_CONST_OR_PURE_P (decl))
!         l->looping = false;
      }
    if (TREE_NOTHROW (decl))
      l->can_throw = false;
--- 530,546 ----
    if (TREE_READONLY (decl))
      {
        l->pure_const_state = IPA_CONST;
!       l->state_previously_known = IPA_CONST;
        if (!DECL_LOOPING_CONST_OR_PURE_P (decl))
!         l->looping = false, l->looping_previously_known = false;
      }
    if (DECL_PURE_P (decl))
      {
        if (l->pure_const_state != IPA_CONST)
          l->pure_const_state = IPA_PURE;
!       l->state_previously_known = IPA_PURE;
        if (!DECL_LOOPING_CONST_OR_PURE_P (decl))
!         l->looping = false, l->looping_previously_known = false;
      }
    if (TREE_NOTHROW (decl))
      l->can_throw = false;
*************** propagate (void)
*** 728,739 ****
  	  enum pure_const_state_e this_state = pure_const_state;
  	  bool this_looping = looping;
  
! 	  if (w_l->state_set_in_source != IPA_NEITHER)
! 	    {
! 	      if (this_state > w_l->state_set_in_source)
! 	        this_state = w_l->state_set_in_source;
! 	      this_looping = false;
! 	    }
  
  	  /* All nodes within a cycle share the same info.  */
  	  w_l->pure_const_state = this_state;
--- 730,740 ----
  	  enum pure_const_state_e this_state = pure_const_state;
  	  bool this_looping = looping;
  
! 	  if (w_l->state_previously_known != IPA_NEITHER
! 	      && this_state > w_l->state_previously_known)
!             this_state = w_l->state_previously_known;
! 	  if (!w_l->looping_previously_known)
! 	    this_looping = false;
  
  	  /* All nodes within a cycle share the same info.  */
  	  w_l->pure_const_state = this_state;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]